mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
replace stashBox validation (#5187)
This commit is contained in:
parent
879c20efc7
commit
601a16b5cb
1 changed files with 6 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ package config
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
|
@ -1097,7 +1098,10 @@ func (i *Config) ValidateCredentials(username string, password string) bool {
|
|||
return username == authUser && err == nil
|
||||
}
|
||||
|
||||
var stashBoxRe = regexp.MustCompile("^http.*graphql$")
|
||||
func stashBoxValidate(str string) bool {
|
||||
u, err := url.Parse(str)
|
||||
return err == nil && u.Scheme != "" && u.Host != "" && strings.HasSuffix(u.Path, "/graphql")
|
||||
}
|
||||
|
||||
type StashBoxInput struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
|
|
@ -1118,7 +1122,7 @@ func (i *Config) ValidateStashBoxes(boxes []*StashBoxInput) error {
|
|||
return &StashBoxError{msg: "endpoint cannot be blank"}
|
||||
}
|
||||
|
||||
if !stashBoxRe.Match([]byte(box.Endpoint)) {
|
||||
if !stashBoxValidate(box.Endpoint) {
|
||||
return &StashBoxError{msg: "endpoint is invalid"}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue