From d92d0dcfa9f68d2dbb32fef1a1221b4367f5404f Mon Sep 17 00:00:00 2001 From: sisidovski Date: Wed, 8 Nov 2023 12:23:03 -0800 Subject: [PATCH] Use kUnicodeSets (v regexp flag) in URLPattern This CL follows the recent spec update in [1]. After this CL, the regular expression works with the unicodeSet mode, which allows the API to interpret set notations, multi-codepoint properties etc. Actually, this CL ends up only adding the support for set notations. At the moment the API doesn't accept unicode character class escape (\p{}, \P{}) [2], thus we wouldn't add the multi-codepoint match functionarity. There are some incompatibility between "u" and "v", some patterns are privously valid but now errors. However, from UMA the impact looks very limited, it's only around 0.3% of the total constructor calls. So this CL changes the default flag to "v". Also add a kill switch. [1] https://github.com/WICG/urlpattern/issues/178 [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape Change-Id: I14cc3420d57cca44c0c25867d05802a8a666cd8c Bug: 1482263 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4861342 Reviewed-by: Jeremy Roman Commit-Queue: Shunya Shishido Cr-Commit-Position: refs/heads/main@{#1221823} --- urlpattern/resources/urlpatterntestdata.json | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/urlpattern/resources/urlpatterntestdata.json b/urlpattern/resources/urlpatterntestdata.json index 4a05e4c95cbb67..058079bb6d17ac 100644 --- a/urlpattern/resources/urlpatterntestdata.json +++ b/urlpattern/resources/urlpatterntestdata.json @@ -2829,5 +2829,29 @@ "search": { "input": "q=*&v=?&hmm={}&umm=()", "groups": {} }, "hash": { "input": "foo", "groups": {} } } + }, + { + "pattern": [{ "pathname": "/([[a-z]--a])" }], + "inputs": [{ "pathname": "/a" }], + "expected_match": null + }, + { + "pattern": [{ "pathname": "/([[a-z]--a])" }], + "inputs": [{ "pathname": "/z" }], + "expected_match": { + "pathname": { "input": "/z", "groups": { "0": "z" } } + } + }, + { + "pattern": [{ "pathname": "/([\\d&&[0-1]])" }], + "inputs": [{ "pathname": "/0" }], + "expected_match": { + "pathname": { "input": "/0", "groups": { "0": "0" } } + } + }, + { + "pattern": [{ "pathname": "/([\\d&&[0-1]])" }], + "inputs": [{ "pathname": "/3" }], + "expected_match": null } ]