shithub: hugo

Download patch

ref: 0586bf0dc3c65c040f7fde2379e9edf4dc8fb90d
parent: 8d8e9dde51c50f27ff1709eed30a7c231c13022f
author: Bjørn Erik Pedersen <[email protected]>
date: Sat Feb 6 21:12:33 EST 2016

Use filepath.Join in locale resource getting

--- a/tpl/template_resources.go
+++ b/tpl/template_resources.go
@@ -158,15 +158,7 @@
 
 // resGetLocal loads the content of a local file
 func resGetLocal(url string, fs afero.Fs) ([]byte, error) {
-	p := ""
-	workingDir := viper.GetString("WorkingDir")
-	if workingDir != "" {
-		p = workingDir
-		if !strings.HasSuffix(p, helpers.FilePathSeparator) {
-			p = p + helpers.FilePathSeparator
-		}
-	}
-	filename := p + url
+	filename := filepath.Join(viper.GetString("WorkingDir"), url)
 	if e, err := helpers.Exists(filename, fs); !e {
 		return nil, err
 	}