diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-25 09:01:26 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-25 10:29:46 +0300 |
commit | 135c1398b2531103d3aeebaee66f19ef799f1f52 (patch) | |
tree | 2a322afad0c37c41afc870305c94f843ad372fc9 /internal/redirects/redirects.go | |
parent | f0bbf3c22d67d55457db27e5e41789c26789be82 (diff) |
chore: process the first 1000 rules only
Diffstat (limited to 'internal/redirects/redirects.go')
-rw-r--r-- | internal/redirects/redirects.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/internal/redirects/redirects.go b/internal/redirects/redirects.go index fafeaf4b..24ce8692 100644 --- a/internal/redirects/redirects.go +++ b/internal/redirects/redirects.go @@ -55,7 +55,6 @@ var ( errUnsupportedStatus = errors.New("status not supported") errNoForce = errors.New("force! not supported") errTooManyPathSegments = fmt.Errorf("url path cannot contain more than %d forward slashes", maxPathSegments) - errTooManyRules = fmt.Errorf("_redirects file may not contain more than %d rules", maxRuleCount) regexpPlaceholder = regexp.MustCompile(`(?i)/:[a-z]+`) ) @@ -73,11 +72,21 @@ func (r *Redirects) Status() string { messages := make([]string, 0, len(r.rules)+1) messages = append(messages, fmt.Sprintf("%d rules", len(r.rules))) - if err := validateRedirectsFile(r); err != nil { - messages = append(messages, fmt.Sprintf("error: %s", err.Error())) - } - for i, rule := range r.rules { + if i >= maxRuleCount { + messages = append([]string{ + fmt.Sprintf( + "The _redirects file contains (%d) rules, more than the maximum of %d rules. Only the first %d rules will be processed.", + len(r.rules), + maxRuleCount, + maxRuleCount, + )}, + messages..., + ) + + break + } + if err := validateRule(rule); err != nil { messages = append(messages, fmt.Sprintf("rule %d: error: %s", i+1, err.Error())) } else { |