swifter icon indicating copy to clipboard operation
swifter copied to clipboard

'**' does not work with single path element

Open drekka opened this issue 4 years ago • 0 comments

I've tried to use '' in a route, but it's not working when there is only a single path element. ie. /a//b matches /a/x/y/b but does not match /a/x/b. It appears to be the equivalent of >=2 path elements where I think it should be >= 1 path elements.

So if I modify the relevant unit test like this:

    func testHttpRouterMultiplePathSegmentWildcards() {

        router.register(nil, path: "/a/**/e/f/g", handler: { _ in
            return .ok(.htmlBody("OK"))
        })

        XCTAssertNil(router.route(nil, path: "/"))
        XCTAssertNil(router.route(nil, path: "/a"))
        XCTAssertNotNil(router.route(nil, path: "/a/b/e/f/g"))      // <- I would expect this to pass, but it fails.
        XCTAssertNotNil(router.route(nil, path: "/a/b/c/d/e/f/g"))
        XCTAssertNil(router.route(nil, path: "/a/e/f/g"))
    }

drekka avatar Jul 07 '21 05:07 drekka