mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Minor cleanup of some of the resource getting code
This commit is contained in:
parent
b3a70abe40
commit
8d8e9dde51
1 changed files with 7 additions and 6 deletions
|
@ -159,18 +159,19 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
|
||||||
// resGetLocal loads the content of a local file
|
// resGetLocal loads the content of a local file
|
||||||
func resGetLocal(url string, fs afero.Fs) ([]byte, error) {
|
func resGetLocal(url string, fs afero.Fs) ([]byte, error) {
|
||||||
p := ""
|
p := ""
|
||||||
if viper.GetString("WorkingDir") != "" {
|
workingDir := viper.GetString("WorkingDir")
|
||||||
p = viper.GetString("WorkingDir")
|
if workingDir != "" {
|
||||||
if helpers.FilePathSeparator != p[len(p)-1:] {
|
p = workingDir
|
||||||
|
if !strings.HasSuffix(p, helpers.FilePathSeparator) {
|
||||||
p = p + helpers.FilePathSeparator
|
p = p + helpers.FilePathSeparator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jFile := p + url
|
filename := p + url
|
||||||
if e, err := helpers.Exists(jFile, fs); !e {
|
if e, err := helpers.Exists(filename, fs); !e {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := fs.Open(jFile)
|
f, err := fs.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue