diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-25 07:15:04 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-25 10:29:46 +0300 |
commit | f0bbf3c22d67d55457db27e5e41789c26789be82 (patch) | |
tree | 9dcafe2a982470ca51fcc99ce4ba623faa49be98 /internal/redirects/redirects.go | |
parent | 3a70cb0981085ec28ba3ab870c86e3abb32d64fd (diff) |
Revert "feat: validate rules length after parsing"
This reverts commit 42fcbc6b890e23294e35ad30553d9adea7302bd8.
Diffstat (limited to 'internal/redirects/redirects.go')
-rw-r--r-- | internal/redirects/redirects.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/redirects/redirects.go b/internal/redirects/redirects.go index d214c64d..fafeaf4b 100644 --- a/internal/redirects/redirects.go +++ b/internal/redirects/redirects.go @@ -55,7 +55,7 @@ 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 contains more than the maximum %d rules, so no rules will be processed", maxRuleCount) + errTooManyRules = fmt.Errorf("_redirects file may not contain more than %d rules", maxRuleCount) regexpPlaceholder = regexp.MustCompile(`(?i)/:[a-z]+`) ) @@ -73,6 +73,10 @@ 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 err := validateRule(rule); err != nil { messages = append(messages, fmt.Sprintf("rule %d: error: %s", i+1, err.Error())) @@ -132,9 +136,5 @@ func ParseRedirects(ctx context.Context, root vfs.Root) *Redirects { return &Redirects{error: errFailedToParseConfig} } - if len(redirectRules) > maxRuleCount { - return &Redirects{error: errTooManyRules} - } - return &Redirects{rules: redirectRules} } |