aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
Diffstat (limited to 'skate')
-rw-r--r--skate/cmd/skate-cleanup/main.go11
-rw-r--r--skate/url.go6
2 files changed, 4 insertions, 13 deletions
diff --git a/skate/cmd/skate-cleanup/main.go b/skate/cmd/skate-cleanup/main.go
index 72b258a..d4d5f5a 100644
--- a/skate/cmd/skate-cleanup/main.go
+++ b/skate/cmd/skate-cleanup/main.go
@@ -59,15 +59,6 @@ func main() {
}
}
-func hasAnyPrefix(s string, prefixes []string) bool {
- for _, p := range prefixes {
- if strings.HasPrefix(s, p) {
- return true
- }
- }
- return false
-}
-
// urlFilter parses finds the first URL.
func urlFilter(p []byte) ([]byte, error) {
parts := strings.Split(string(p), *delimiter)
@@ -87,7 +78,7 @@ func urlFilter(p []byte) ([]byte, error) {
if url == "" && *skipNonMatches {
return nil, nil
}
- if len(allowedSchemas) > 0 && !hasAnyPrefix(url, allowedSchemas) {
+ if len(allowedSchemas) > 0 && !skate.HasAnyPrefix(url, allowedSchemas) {
return nil, nil
}
if len(parts) == 1 || *index == len(parts) {
diff --git a/skate/url.go b/skate/url.go
index 4ea406e..f619b24 100644
--- a/skate/url.go
+++ b/skate/url.go
@@ -28,7 +28,7 @@ var (
// really work, as syntactically valid URL strings may still be improbable
// URLs, e.g. http://!!!x.com, etc.
func SanitizeURL(s string) string {
- if !hasAnyPrefix(s, okPrefixes) {
+ if !HasAnyPrefix(s, okPrefixes) {
s = sanitizeRaw(s)
if s == "" {
return s
@@ -82,8 +82,8 @@ func sanitizeRaw(s string) string {
return "http://" + s
}
-// hasAnyPrefixes returns true, if any of the prefixes matches string s.
-func hasAnyPrefix(s string, prefix []string) bool {
+// HasAnyPrefixes returns true, if any of the prefixes matches string s.
+func HasAnyPrefix(s string, prefix []string) bool {
for _, p := range prefix {
if strings.HasPrefix(s, p) {
return true