forked from forgejo/forgejo
Added support for gopher URLs. (#14749)
* Added support for gopher URLs. * Add setting and make this user settable instead Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
1a1ce9b721
commit
9b33d18899
6 changed files with 54 additions and 1 deletions
|
@ -52,6 +52,25 @@ func IsValidURL(uri string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// IsValidSiteURL checks if URL is valid
|
||||
func IsValidSiteURL(uri string) bool {
|
||||
u, err := url.ParseRequestURI(uri)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if !validPort(portOnly(u.Host)) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, scheme := range setting.Service.ValidSiteURLSchemes {
|
||||
if scheme == u.Scheme {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsAPIURL checks if URL is current Gitea instance API URL
|
||||
func IsAPIURL(uri string) bool {
|
||||
return strings.HasPrefix(strings.ToLower(uri), strings.ToLower(setting.AppURL+"api"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue