Files
torrent-indexer/utils/util.go
Felipe Marinho 88d6d506bf Feat/Search support (#25)
* new: feat: add search support with meilisearch

* new: feat: add search interface

* new: feat: add new audio mappings

* chg: fix: add meilisearch docs

* chg: fix: lint issues

* chg: feat: add br flag

* chg: fix: use the same user agent

* chg: fix: bludv (again)

* chg: fix: lint issue
2024-12-13 11:54:55 -03:00

33 lines
771 B
Go

package utils
import "regexp"
func Filter[A any](arr []A, f func(A) bool) []A {
var res []A
res = make([]A, 0)
for _, v := range arr {
if f(v) {
res = append(res, v)
}
}
return res
}
func IsValidHTML(input string) bool {
// Check for <!DOCTYPE> declaration (case-insensitive)
doctypeRegex := regexp.MustCompile(`(?i)<!DOCTYPE\s+html>`)
if !doctypeRegex.MatchString(input) {
return false
}
// Check for <html> and </html> tags (case-insensitive)
htmlTagRegex := regexp.MustCompile(`(?i)<html[\s\S]*?>[\s\S]*?</html>`)
if !htmlTagRegex.MatchString(input) {
return false
}
// Check for <body> and </body> tags (case-insensitive)
bodyTagRegex := regexp.MustCompile(`(?i)<body[\s\S]*?>[\s\S]*?</body>`)
return bodyTagRegex.MatchString(input)
}