mirror of
https://github.com/miniflux/v2.git
synced 2025-08-21 18:11:09 +00:00
feat: add new settings option to allow external fonts
This commit is contained in:
parent
600dea6ce5
commit
e555e442fb
32 changed files with 257 additions and 56 deletions
|
@ -7,8 +7,11 @@ import (
|
|||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var domainRegex = regexp.MustCompile(`^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$`)
|
||||
|
||||
// ValidateRange makes sure the offset/limit values are valid.
|
||||
func ValidateRange(offset, limit int) error {
|
||||
if offset < 0 {
|
||||
|
@ -43,3 +46,24 @@ func IsValidURL(absoluteURL string) bool {
|
|||
_, err := url.ParseRequestURI(absoluteURL)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func IsValidDomain(domain string) bool {
|
||||
domain = strings.ToLower(domain)
|
||||
|
||||
if len(domain) < 1 || len(domain) > 253 {
|
||||
return false
|
||||
}
|
||||
|
||||
return domainRegex.MatchString(domain)
|
||||
}
|
||||
|
||||
func IsValidDomainList(value string) bool {
|
||||
domains := strings.Split(strings.TrimSpace(value), " ")
|
||||
for _, domain := range domains {
|
||||
if !IsValidDomain(domain) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue