Switched redirect status code back from 307 to 303, and defined it as a const.

This commit is contained in:
Seednode 2022-10-20 17:12:29 -05:00
parent 8e4c9c5e32
commit e39950de68
3 changed files with 12 additions and 8 deletions

View File

@ -277,6 +277,7 @@ func fileExists(path string) (bool, error) {
func pathIsValid(filePath string, paths []string) bool {
var matchesPrefix = false
for i := 0; i < len(paths); i++ {
if strings.HasPrefix(filePath, paths[i]) {
matchesPrefix = true

View File

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

View File

@ -16,8 +16,11 @@ import (
"time"
)
const LOGDATE string = "2006-01-02T15:04:05.000-07:00"
const PREFIX string = "/src"
const (
LOGDATE string = "2006-01-02T15:04:05.000-07:00"
PREFIX string = "/src"
RedirectStatusCode int = http.StatusSeeOther
)
type Filters struct {
Includes []string
@ -287,7 +290,7 @@ func serveHtmlHandler(paths []string) appHandler {
filePath,
generateQueryParams(&filters, sortOrder),
)
http.Redirect(w, r, newUrl, http.StatusTemporaryRedirect)
http.Redirect(w, r, newUrl, RedirectStatusCode)
case r.URL.Path == "/" && sortOrder == "asc" && refererUri == "":
filePath, err := pickFile(paths, &filters, sortOrder)
if err != nil && err == ErrNoImagesFound {
@ -313,7 +316,7 @@ func serveHtmlHandler(paths []string) appHandler {
filePath,
generateQueryParams(&filters, sortOrder),
)
http.Redirect(w, r, newUrl, http.StatusTemporaryRedirect)
http.Redirect(w, r, newUrl, RedirectStatusCode)
case r.URL.Path == "/" && sortOrder == "desc" && refererUri != "":
query, err := url.QueryUnescape(refererUri)
if err != nil {
@ -357,7 +360,7 @@ func serveHtmlHandler(paths []string) appHandler {
filePath,
generateQueryParams(&filters, sortOrder),
)
http.Redirect(w, r, newUrl, http.StatusTemporaryRedirect)
http.Redirect(w, r, newUrl, RedirectStatusCode)
case r.URL.Path == "/" && sortOrder == "desc" && refererUri == "":
filePath, err := pickFile(paths, &filters, sortOrder)
if err != nil && err == ErrNoImagesFound {
@ -383,7 +386,7 @@ func serveHtmlHandler(paths []string) appHandler {
filePath,
generateQueryParams(&filters, sortOrder),
)
http.Redirect(w, r, newUrl, http.StatusTemporaryRedirect)
http.Redirect(w, r, newUrl, RedirectStatusCode)
case r.URL.Path == "/":
filePath, err := pickFile(paths, &filters, sortOrder)
if err != nil && err == ErrNoImagesFound {
@ -399,7 +402,7 @@ func serveHtmlHandler(paths []string) appHandler {
filePath,
generateQueryParams(&filters, sortOrder),
)
http.Redirect(w, r, newUrl, http.StatusTemporaryRedirect)
http.Redirect(w, r, newUrl, RedirectStatusCode)
default:
filePath := r.URL.Path