diff options
Diffstat (limited to 'skate')
-rw-r--r-- | skate/url.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/skate/url.go b/skate/url.go index e77d331..422d3ed 100644 --- a/skate/url.go +++ b/skate/url.go @@ -3,6 +3,7 @@ package skate import ( "index/suffixarray" "regexp" + "sort" "strings" ) @@ -29,15 +30,14 @@ func SanitizeURL(s string) string { return s } } - var ( - // seems to only be about 15% of total time spent - index = suffixarray.New([]byte(s)) - indices = index.Lookup([]byte("http"), -1) - ) + // 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 { // ISSN-2177-4129periodicos.ufpel.edu.br/ojs2/index.php/Memoriahttp://dx.doi.org/10.15210/rmr.v8i14.7485 s = s[indices[0]:] } else if len(indices) > 1 { + sort.Ints(indices) // http://ailab.ist.psu.edu/bcpred/SVMTriP:http://sysbio.unl.edu/SVMTriP/prediction.phpBcell s = s[indices[0]:indices[1]] // only use the first s = strings.TrimRight(s, ":") @@ -67,10 +67,9 @@ func sanitizeRaw(s string) string { if !strings.Contains(s, ".") { return "" } - var ( - index = suffixarray.New([]byte(s)) - indices = index.Lookup([]byte("www."), 1) - ) + index := suffixarray.New([]byte(s)) + indices := index.Lookup([]byte("www."), 1) + sort.Ints(indices) if len(indices) > 0 { return "http://" + s[indices[0]:] } |