return p, nil
}
-// TODO(jba): remove this; it is unused.
-func isValidHTTPToken(s string) bool {
- if s == "" {
- return false
- }
- // See https://www.rfc-editor.org/rfc/rfc9110#section-5.6.2.
- for _, r := range s {
- if !unicode.IsLetter(r) && !unicode.IsDigit(r) && !strings.ContainsRune("!#$%&'*+.^_`|~-", r) {
- return false
- }
- }
- return true
-}
-
func isValidWildcardName(s string) bool {
if s == "" {
return false
slices.Equal(p1.segments, p2.segments)
}
-func TestIsValidHTTPToken(t *testing.T) {
- for _, test := range []struct {
- in string
- want bool
- }{
- {"", false},
- {"GET", true},
- {"get", true},
- {"white space", false},
- {"#!~", true},
- {"a-b1_2", true},
- {"notok)", false},
- } {
- got := isValidHTTPToken(test.in)
- if g, w := got, test.want; g != w {
- t.Errorf("%q: got %t, want %t", test.in, g, w)
- }
- }
-}
-
func mustParsePattern(tb testing.TB, s string) *pattern {
tb.Helper()
p, err := parsePattern(s)