mirror of
https://github.com/packwiz/packwiz.git
synced 2025-05-03 19:16:30 +02:00
Handle filepath/path translation properly
This commit is contained in:
parent
2b12e2c390
commit
44cd63923e
@ -39,7 +39,7 @@ var serveCmd = &cobra.Command{
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
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) {
|
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||||
path := strings.TrimPrefix(req.URL.Path, "/")
|
path := strings.TrimPrefix(req.URL.Path, "/")
|
||||||
@ -50,7 +50,7 @@ var serveCmd = &cobra.Command{
|
|||||||
path = indexPath
|
path = indexPath
|
||||||
// Must be done here, to ensure all paths gain the lock at some point
|
// Must be done here, to ensure all paths gain the lock at some point
|
||||||
refreshMutex.RLock()
|
refreshMutex.RLock()
|
||||||
} else if path == viper.GetString("pack-file") {
|
} else if path == filepath.ToSlash(viper.GetString("pack-file")) {
|
||||||
found = true
|
found = true
|
||||||
if viper.GetBool("serve.refresh") {
|
if viper.GetBool("serve.refresh") {
|
||||||
// Get write lock, to do a refresh
|
// Get write lock, to do a refresh
|
||||||
@ -102,7 +102,7 @@ var serveCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if found {
|
if found {
|
||||||
path = filepath.Join(filepath.Dir(indexPath), path)
|
path = filepath.Join(filepath.Dir(indexPath), filepath.FromSlash(path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer refreshMutex.RUnlock()
|
defer refreshMutex.RUnlock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user