fix(URLPattern): Handle search parameters correctly in URLPattern with base#49
Conversation
…parameters when a base URL is provided. This fixes the discrepancy where URLPattern in Deno was returning null for URLs with search parameters, unlike the behavior observed in Chrome. Adjusted URLPattern parsing to include search parameters when matching against base URLs. Fixes #denoland/deno#24266
|
@crowlKats As I previously mentioned, I found that when the "URLPattern" is constructed in Deno, it attempts to establish the pattern; however, if no pattern is specified, the default pattern for the "search field" is set to None("") so in 'p.exec' , it attempts to extract patterns and compares them with those generated by the constructor. check out this example, which attempts to match ?id=2 with ?id=3 ,the result no match, null was returned. and check out this example, it tries to match ?id=3 with ?id=3 ,the result matched, The object was returned So, if no pattern was specified, the search pattern will be set to NONE, meaning there would be no match and no result. So I wrote change to set the search pattern default value to . I have an additional fix. I like it better; it's more like Chrome behavior, but I'll have to rewrite every test in the "url-pattern" from start if you want this change. It will take me a few days to complete the rewrites. so if we apply this change, we can remove our construct code of UrlPattern Init ,this is simpler and has fewer difficult code snippets. |
|
@crowlKats |
|
@yazan-abdalrahman the tests in the JSON file come from WPT, which are not to be changed since they match the standard specification. |
|
@crowlKats #50 |







…parameters when a base URL is provided. This fixes the discrepancy where URLPattern in Deno was returning null for URLs with search parameters, unlike the behavior observed in Chrome.
Adjusted URLPattern parsing to include search parameters when matching against base URLs. Fixes #denoland/deno#24266