1
0
mirror of https://github.com/packwiz/packwiz.git synced 2025-05-02 18:46:31 +02:00

Handle filepath/path translation properly

This commit is contained in:
comp500 2019-09-19 00:16:09 +01:00
parent 2b12e2c390
commit 44cd63923e

@ -39,7 +39,7 @@ var serveCmd = &cobra.Command{
fmt.Println(err)
os.Exit(1)
}
indexPath := filepath.Join(filepath.Dir(viper.GetString("pack-file")), pack.Index.File)
indexPath := filepath.Join(filepath.Dir(viper.GetString("pack-file")), filepath.FromSlash(pack.Index.File))
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
path := strings.TrimPrefix(req.URL.Path, "/")
@ -50,7 +50,7 @@ var serveCmd = &cobra.Command{
path = indexPath
// Must be done here, to ensure all paths gain the lock at some point
refreshMutex.RLock()
} else if path == viper.GetString("pack-file") {
} else if path == filepath.ToSlash(viper.GetString("pack-file")) {
found = true
if viper.GetBool("serve.refresh") {
// Get write lock, to do a refresh
@ -102,7 +102,7 @@ var serveCmd = &cobra.Command{
}
}
if found {
path = filepath.Join(filepath.Dir(indexPath), path)
path = filepath.Join(filepath.Dir(indexPath), filepath.FromSlash(path))
}
}
defer refreshMutex.RUnlock()