Added strings.TrimPrefix to refererUri so sorting works with the new setup

This commit is contained in:
Seednode 2023-06-03 18:37:06 -05:00
parent 3d8d4c3869
commit 7780b8eaa9
2 changed files with 15 additions and 2 deletions

View File

@ -11,7 +11,7 @@ import (
)
const (
Version string = "0.51.1"
Version string = "0.51.2"
)
var (

View File

@ -795,9 +795,12 @@ func serveRoot(paths []string, Regexes *Regexes, index *Index) httprouter.Handle
refererUri, err := stripQueryParams(refererToUri(r.Referer()))
if err != nil {
fmt.Println(err)
return
}
strippedRefererUri := strings.TrimPrefix(refererUri, ImagePrefix)
filters := &Filters{
includes: splitQueryParams(r.URL.Query().Get("include"), Regexes),
excludes: splitQueryParams(r.URL.Query().Get("exclude"), Regexes),
@ -810,9 +813,10 @@ func serveRoot(paths []string, Regexes *Regexes, index *Index) httprouter.Handle
var filePath string
if refererUri != "" {
filePath, err = nextFile(refererUri, sortOrder, Regexes)
filePath, err = nextFile(strippedRefererUri, sortOrder, Regexes)
if err != nil {
fmt.Println(err)
return
}
}
@ -837,6 +841,7 @@ func serveRoot(paths []string, Regexes *Regexes, index *Index) httprouter.Handle
return
case err != nil:
fmt.Println(err)
return
}
}
@ -870,6 +875,7 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
exists, err := fileExists(filePath)
if err != nil {
fmt.Println(err)
return
}
if !exists {
@ -881,6 +887,7 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
image, err := isSupportedFileType(filePath)
if err != nil {
fmt.Println(err)
return
}
@ -896,6 +903,7 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
dimensions, err = imageDimensions(filePath)
if err != nil {
fmt.Println(err)
return
}
}
@ -942,6 +950,7 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
_, err = io.WriteString(w, gohtml.Format(htmlBody.String()))
if err != nil {
fmt.Println(err)
return
}
}
@ -957,6 +966,7 @@ func serveFavicons() httprouter.Handle {
}
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
w.Write(data)
}
}
@ -966,6 +976,7 @@ func serveVersion() httprouter.Handle {
data := []byte(fmt.Sprintf("roulette v%s\n", Version))
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
w.Write(data)
}
}
@ -1040,7 +1051,9 @@ func ServePage(args []string) error {
go func() {
<-gracefulShutdown
stats.Export(statisticsFile)
os.Exit(0)
}()
}