From 3101af8a5c96ccd2751105785327a21ee55aa5c4 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Thu, 21 Nov 2019 01:09:21 -0800 Subject: [PATCH] utils_sanitise.go: strip protocol before trailer Fixes https://gitlab.com/commento/commento/issues/176 --- api/utils_sanitise.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/utils_sanitise.go b/api/utils_sanitise.go index bf59643..4b862f2 100644 --- a/api/utils_sanitise.go +++ b/api/utils_sanitise.go @@ -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?://[^/]*)`)