mirror of
https://github.com/nxshock/gallery.git
synced 2024-11-27 00:11:00 +05:00
Fix issues with Windows paths
This commit is contained in:
parent
41d00de7b7
commit
a0300680bb
@ -20,11 +20,17 @@ func loadConfig(path string) (*Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
config.WorkingDirectory = filepath.ToSlash(config.WorkingDirectory)
|
||||
|
||||
if len(config.WorkingDirectory) > 0 && string(config.WorkingDirectory[len(config.WorkingDirectory)-1]) != "/" {
|
||||
config.WorkingDirectory += "/"
|
||||
}
|
||||
|
||||
workingDirectory, err := filepath.Abs(config.WorkingDirectory)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.WorkingDirectory = workingDirectory
|
||||
config.WorkingDirectory = filepath.ToSlash(workingDirectory)
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
|
@ -15,7 +15,12 @@ func getResponse(path string) ([]Item, error) {
|
||||
}
|
||||
|
||||
for i := range fileNames {
|
||||
fileNames[i] = strings.TrimPrefix(filepath.ToSlash(fileNames[i]), filepath.ToSlash(config.WorkingDirectory))[1:] // TODO: check is first slash properly removed
|
||||
prefix := config.WorkingDirectory
|
||||
if string(prefix[len(prefix)-1]) == "/" {
|
||||
prefix = prefix[:len(prefix)-1]
|
||||
}
|
||||
|
||||
fileNames[i] = strings.TrimPrefix(filepath.ToSlash(fileNames[i]), prefix)[1:] // TODO: check is first slash properly removed
|
||||
}
|
||||
|
||||
items := make([]Item, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user