Skip to content
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

URLPattern with search parameters and base url doesn't work #24266

Closed
irustm opened this issue Jun 19, 2024 · 3 comments · Fixed by #24741
Closed

URLPattern with search parameters and base url doesn't work #24266

irustm opened this issue Jun 19, 2024 · 3 comments · Fixed by #24741
Labels
bug Something isn't working correctly ext/url related to ext/url web related to Web APIs

Comments

@irustm
Copy link

irustm commented Jun 19, 2024

Version: Deno 1.41, 1.44

deno repl   
Deno 1.44.2

> const p = new URLPattern("/api/data/", "http://localhost:8000")
p.exec("http://localhost:8000/api/data/?w=1&g=2")

null
// Chrome 126.0.6478.62

const p = new URLPattern("/api/data/", "http://localhost:8000")
p.exec("http://localhost:8000/api/data/?w=1&g=2")

{Object}

Deno 1.44.2
exit using ctrl+d, ctrl+c, or close()
> const pattern = new URLPattern("/books/:id(\\d+)", "https://example.com");
console.log(pattern.test("https://example.com/books/123"))
true
console.log(pattern.test("https://example.com/books/123?d=1"))
false

// Chrome 126.0.6478.62

const pattern = new URLPattern("/books/:id(\\d+)", "https://example.com");
console.log(pattern.test("https://example.com/books/123"))
true
console.log(pattern.test("https://example.com/books/123?d=1"))
true
@lucacasonato lucacasonato added bug Something isn't working correctly ext/url related to ext/url web related to Web APIs labels Jun 20, 2024
@yazan-abdalrahman
Copy link
Contributor

@irustm ,

Hi, I'm new to Deno. Could you give me more information on this issue, including how to reproduce it and what is expected result?

@yazan-abdalrahman
Copy link
Contributor

the issue when exec query in deno its return null ?
image
image
but it works in chrome right?

yazan-abdalrahman added a commit to yazan-abdalrahman/deno that referenced this issue Jul 18, 2024
Ensure that URLPattern correctly parses and matches URLs with search 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#24266
@yazan-abdalrahman
Copy link
Contributor

yazan-abdalrahman commented Jul 18, 2024

@lucacasonato @bartlomieju ,
I found the issue in building the URLPattern in deno it set the default value of search as None and in another fields, it put empty string, and I founded in chrome it but wildcard () so I added a code to add wildcard () when defaults None or empty.

// in chrome
image

// before set default value of search field as wildcard (*)
image

// after set default value of search field as wildcard (*)
image

But I still don't know where I can add tests for the code that I pushed. Please let me know where I can add tests for it.

yazan-abdalrahman added a commit to yazan-abdalrahman/rust-urlpattern that referenced this issue Jul 22, 2024
…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
yazan-abdalrahman added a commit to yazan-abdalrahman/rust-urlpattern that referenced this issue Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly ext/url related to ext/url web related to Web APIs
Projects
None yet
3 participants