diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-05-12 23:21:49 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-05-12 23:21:49 +0200 |
commit | 368bf739ac91e2b604897460d1993cfdfab4928c (patch) | |
tree | ad43ba7cde70b2083e080e552498f14e3fa8c650 | |
parent | 71f8167681218a74bee98f0bb7ff0123581ccb49 (diff) | |
download | refcat-368bf739ac91e2b604897460d1993cfdfab4928c.tar.gz refcat-368bf739ac91e2b604897460d1993cfdfab4928c.zip |
cleanup: we require two indices
-rw-r--r-- | skate/url.go | 15 |
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 "" } |