MCPcopy
hub / github.com/caddyserver/caddy / TestPathMatcher

Function TestPathMatcher

modules/caddyhttp/matchers_test.go:172–455  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func TestPathMatcher(t *testing.T) {
173 for i, tc := range []struct {
174 match MatchPath // not URI-encoded because not parsing from a URI
175 input string // should be valid URI encoding (escaped) since it will become part of a request
176 expect bool
177 provisionErr bool
178 }{
179 {
180 match: MatchPath{},
181 input: "/",
182 expect: false,
183 },
184 {
185 match: MatchPath{"/"},
186 input: "/",
187 expect: true,
188 },
189 {
190 match: MatchPath{"/foo/bar"},
191 input: "/",
192 expect: false,
193 },
194 {
195 match: MatchPath{"/foo/bar"},
196 input: "/foo/bar",
197 expect: true,
198 },
199 {
200 match: MatchPath{"/foo/bar/"},
201 input: "/foo/bar",
202 expect: false,
203 },
204 {
205 match: MatchPath{"/foo/bar/"},
206 input: "/foo/bar/",
207 expect: true,
208 },
209 {
210 match: MatchPath{"/foo/bar/", "/other"},
211 input: "/other/",
212 expect: false,
213 },
214 {
215 match: MatchPath{"/foo/bar/", "/other"},
216 input: "/other",
217 expect: true,
218 },
219 {
220 match: MatchPath{"*.ext"},
221 input: "/foo/bar.ext",
222 expect: true,
223 },
224 {
225 match: MatchPath{"*.php"},
226 input: "/index.PHP",
227 expect: true,
228 },
229 {

Callers

nothing calls this directly

Calls 3

WithValueMethod · 0.80
ProvisionMethod · 0.65
MatchWithErrorMethod · 0.65

Tested by

no test coverage detected