utils_sanitise.go: strip protocol before trailer

Fixes https://gitlab.com/commento/commento/issues/176
This commit is contained in:
Adhityaa Chandrasekar 2019-11-21 01:09:21 -08:00
parent 162b11bd7a
commit 3101af8a5c

View File

@ -18,13 +18,13 @@ func emailStrip(email string) string {
}
var https = regexp.MustCompile(`(https?://)`)
var trailingSlash = regexp.MustCompile(`(/*$)`)
var domainTrail = regexp.MustCompile(`(/.*$)`)
func domainStrip(domain string) string {
noSlash := trailingSlash.ReplaceAllString(domain, ``)
noProtocol := https.ReplaceAllString(noSlash, ``)
noProtocol := https.ReplaceAllString(domain, ``)
noTrail := domainTrail.ReplaceAllString(noProtocol, ``)
return noProtocol
return noTrail
}
var pathMatch = regexp.MustCompile(`(https?://[^/]*)`)