Second attempt at fixing Linux builds

This commit is contained in:
Seednode 2022-10-23 16:47:23 -05:00
parent f85749b030
commit 8d50f5a088
3 changed files with 13 additions and 8 deletions

View File

@ -82,7 +82,7 @@ func preparePath(path string) string {
path = filepath.Clean(path) path = filepath.Clean(path)
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
path = filepath.ToSlash(path) path = fmt.Sprintf("/%v", filepath.ToSlash(path))
} }
return path return path

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Version = "0.18.0" var Version = "0.18.1"
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)

View File

@ -296,7 +296,7 @@ func serveHtmlHandler(paths []string, re regexp.Regexp) appHandler {
} }
} }
newUrl := fmt.Sprintf("http://%v/%v%v", newUrl := fmt.Sprintf("http://%v%v%v",
r.Host, r.Host,
preparePath(filePath), preparePath(filePath),
generateQueryParams(&filters, sortOrder), generateQueryParams(&filters, sortOrder),
@ -322,7 +322,7 @@ func serveHtmlHandler(paths []string, re regexp.Regexp) appHandler {
return err return err
} }
newUrl := fmt.Sprintf("http://%v/%v%v", newUrl := fmt.Sprintf("http://%v%v%v",
r.Host, r.Host,
preparePath(filePath), preparePath(filePath),
generateQueryParams(&filters, sortOrder), generateQueryParams(&filters, sortOrder),
@ -366,7 +366,7 @@ func serveHtmlHandler(paths []string, re regexp.Regexp) appHandler {
} }
} }
newUrl := fmt.Sprintf("http://%v/%v%v", newUrl := fmt.Sprintf("http://%v%v%v",
r.Host, r.Host,
preparePath(filePath), preparePath(filePath),
generateQueryParams(&filters, sortOrder), generateQueryParams(&filters, sortOrder),
@ -392,11 +392,12 @@ func serveHtmlHandler(paths []string, re regexp.Regexp) appHandler {
return err return err
} }
newUrl := fmt.Sprintf("http://%v/%v%v", newUrl := fmt.Sprintf("http://%v%v%v",
r.Host, r.Host,
preparePath(filePath), preparePath(filePath),
generateQueryParams(&filters, sortOrder), generateQueryParams(&filters, sortOrder),
) )
fmt.Printf("New URL is %v\n", newUrl)
http.Redirect(w, r, newUrl, RedirectStatusCode) http.Redirect(w, r, newUrl, RedirectStatusCode)
case r.URL.Path == "/": case r.URL.Path == "/":
filePath, err := pickFile(paths, &filters, sortOrder) filePath, err := pickFile(paths, &filters, sortOrder)
@ -408,14 +409,18 @@ func serveHtmlHandler(paths []string, re regexp.Regexp) appHandler {
return err return err
} }
newUrl := fmt.Sprintf("http://%v/%v%v", newUrl := fmt.Sprintf("http://%v%v%v",
r.Host, r.Host,
preparePath(filePath), preparePath(filePath),
generateQueryParams(&filters, sortOrder), generateQueryParams(&filters, sortOrder),
) )
http.Redirect(w, r, newUrl, RedirectStatusCode) http.Redirect(w, r, newUrl, RedirectStatusCode)
default: default:
filePath := strings.TrimPrefix(r.URL.Path, "/") filePath := r.URL.Path
if runtime.GOOS == "windows" {
filePath = strings.TrimPrefix(filePath, "/")
}
exists, err := fileExists(filePath) exists, err := fileExists(filePath)
if err != nil { if err != nil {