From 9bc7de9b135cf92c7c4f041ad7901e9c3ba12004 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 22 Aug 2024 05:44:09 -0700 Subject: fix(urlpattern): fallback to empty string for undefined group values (#25151) This change was introduced in #24741, but due to the change in behaviour, we will revert it and re-introduce it in 2.0 --- tests/unit/urlpattern_test.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/urlpattern_test.ts b/tests/unit/urlpattern_test.ts index 3c1fb0cf1..65c224173 100644 --- a/tests/unit/urlpattern_test.ts +++ b/tests/unit/urlpattern_test.ts @@ -63,3 +63,9 @@ Deno.test(function urlPatternWithPrototypePollution() { RegExp.prototype.exec = originalExec; } }); + +Deno.test(function urlPatternEmptyFallback() { + const p = new URLPattern({ pathname: "/foo/bar{/:qaz}?" }); + const match = p.exec("https://example.com/foo/bar"); + assertEquals(match!.pathname.groups.qaz, ""); +}); -- cgit v1.2.3