-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Certain URLPatterns don't work; missing 'not' condition #21
Comments
Thank you @screenspan for reporting this! Currently the API intentionally prohibits the URLPattern input with having regular expressions because from security concerns. Although it's not merged yet, we have a mention in the proposed spec. You can check if your URLPattern input has a regexp or not, by using hasRegExpGroups.
Agree, that's not a smart solution, but currently having multiple patterns is the right approach.
I understand this is important for the debug, but this is more like a chrome DevTools feature. If possible, could you file a bug to https://crbug.com/ ? |
Thank you for the report, As @sisidovski mentioned, using regexp is intentionally prohibited. For the pattern you wrote, I suppose you can also use the
Unfortunately, Chromium only implements the When you hover the network panel entry, router ID will be shown. You can find an associated source by checking the ID in the routes section shown in the Application panel. However, I understand it is not so convenient. As @sisidovski mentioned, please feel free to file a crbug. |
Hi @sisidovski and @yoshisatoyanagisawa , thanks for the additional information. Using the If I understand the proposal for the final form of the API, a
I think that'll be helpful once implemented. Are there any other restrictions on using the URL Pattern API with Static Routing besides custom RegExp groups? I've filed a crbug for the DevTools feature request, so feel free to close this issue if you want. |
Except for prohibiting use of a regular expression (or, what URLPattern think as a regular expression), there should not be any restrictions. One thing you may need an attention to use URLPattern is that an implicit base URL configuration for short-hands. However, since you use the URLPattern object, you should not be affected. I do not come up with anything else. |
FYI, the "not" condition implementation is tracked in https://issues.chromium.org/issues/328565554. |
Note that the not condition has been implemented behind the flag (ServiceWorkerStaticRouterNotConditionEnabled). |
FYI, I2S has been sent. https://groups.google.com/a/chromium.org/g/blink-dev/c/1HxS284iKCE |
Let me mark this resolved.
|
SHORT DESCRIPTION
We'd like to be able to
CURRENT BEHAVIOR
Google Version 123.0.6289.0 (Developer Build) (arm64) on Mac OS 14.3.1
Date: 2024-02-16
The URL Pattern API does allow for alternates using
|
, e.g.But using alternates doesn't currently work in the Service Worker Static Routing API. The following code results in an error:
We therefore have to resort to a verbose way of declaring multiple patterns that does let us bypass the Service Worker:
Result: A matched URL is fetched from the network as per Service Worker Static Routing API.
DESIRED BEHAVIOR
Pattern alternatives
Use pattern alternatives separated by a pipe character, e.g.
Exclude URL patterns using 'not' condition
Add all routes except for certain patterns by using a
not
condition, as the URL Pattern API apparently doesn't have a way to exclude patterns.Show 'Source' in Network Panel
Currently routed via Service Worker Static Routing API are annotated by
(ServiceWorker router)
in the Network panel.Ideally, the source would also be displayed, e.g.
(ServiceWorker: routed to network)
The text was updated successfully, but these errors were encountered: