aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
Diffstat (limited to 'skate')
-rw-r--r--skate/url.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/skate/url.go b/skate/url.go
index b104651..f81b1d2 100644
--- a/skate/url.go
+++ b/skate/url.go
@@ -21,17 +21,17 @@ var (
// http://agingmind.utdallas.edu/facedb/view/neutral-faces.doi:10.3758/BF03206543.
// http://10.3386/w20634https://doi.org/10.3386/w20634
func SanitizeURL(s string) string {
- var (
- // seems to only be about 15% of total time spent
- index = suffixarray.New([]byte(s))
- indices = index.Lookup([]byte("http"), -1)
- )
if !strings.HasPrefix(s, "http") && !strings.HasPrefix(s, "ftp") {
- s = sanitizeRaw(s, index)
+ s = sanitizeRaw(s)
if s == "" {
return s
}
}
+ var (
+ // seems to only be about 15% of total time spent
+ index = suffixarray.New([]byte(s))
+ indices = index.Lookup([]byte("http"), -1)
+ )
if len(indices) > 1 {
s = s[0:indices[1]] // only use the first
s = strings.TrimRight(s, ":")
@@ -60,7 +60,8 @@ func SanitizeURL(s string) string {
return s
}
-func sanitizeRaw(s string, index *suffixarray.Index) string {
+func sanitizeRaw(s string) string {
+ index := suffixarray.New([]byte(s))
if len(s) < 4 {
return ""
}