aboutsummaryrefslogtreecommitdiff
path: root/scope.go
diff options
context:
space:
mode:
Diffstat (limited to 'scope.go')
-rw-r--r--scope.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/scope.go b/scope.go
index b2e90ea..bda1035 100644
--- a/scope.go
+++ b/scope.go
@@ -115,19 +115,21 @@ func (s *regexpIgnoreScope) Check(link Outlink, depth int) bool {
return true
}
+func compileDefaultIgnorePatterns() []*regexp.Regexp {
+ out := make([]*regexp.Regexp, 0, len(defaultIgnorePatterns))
+ for _, p := range defaultIgnorePatterns {
+ out = append(out, regexp.MustCompile(p))
+ }
+ return out
+}
+
// NewRegexpIgnoreScope returns a Scope that filters out URLs
// according to a list of regular expressions.
-func NewRegexpIgnoreScope(ignores []string) Scope {
- if ignores == nil {
- ignores = defaultIgnorePatterns
- }
- r := regexpIgnoreScope{
- ignores: make([]*regexp.Regexp, 0, len(ignores)),
- }
- for _, i := range ignores {
- r.ignores = append(r.ignores, regexp.MustCompile(i))
+func NewRegexpIgnoreScope(ignores []*regexp.Regexp) Scope {
+ ignores = append(compileDefaultIgnorePatterns(), ignores...)
+ return &regexpIgnoreScope{
+ ignores: ignores,
}
- return &r
}
// NewIncludeRelatedScope always includes resources with TagRelated.