question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

urlParsed doesn't support repeated search params

See original GitHub issue

When making a request to /?foo=bar&foo=baz I would expect pageContext.urlParsed.search to return {foo: ['bar', 'baz']} but instead it returns {foo: 'baz'}.

More in general I think just proving a full url (including host) would be nicer, since then it would be possible to use new URL(pageContext.url).searchParams.getAll('foo'). In addition you could use the hostname when routing (e.g. for multi-tenency).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Dec 16, 2021

Thanks for these thorough insights, very helpful.

Luckily I settled with “search”, so we’re good here.

I actually revamped pageContext.urlParsed; I believe it now satisfy all needs. More infos at https://vite-plugin-ssr.com/pageContext.

To answer OP: update to vps’s latest version and new URLSearchParams(pageContext.urlParsed.searchString||'') will do the trick.

1reaction
ntkoopmancommented, Oct 5, 2021

This is not really the case when you use checkboxes, as every checkbox will have the same query parameter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrieving parameters from a URL - python - Stack Overflow
The url you are referring is a query type and I see that the request object supports a method called arguments to get...
Read more >
net/url: don't parse ';' as a separator in query string ... - GitHub
Form parse error when parameter include SQL Injection test net/http: ParseForm ... Node.js doesn't seem to recognize ';' as a separator.
Read more >
URLSearchParams - Web APIs - MDN Web Docs
Chrome Edge URLSearchParams Full support. Chrome49. Toggle history Full support. Edge... @@iterator Full support. Chrome49. Toggle history Full support. Edge... URLSearchParams() constructor Full support. Chrome49. Toggle...
Read more >
urllib.parse — Parse URLs into components — Python 3.11.1 ...
The URL parsing functions focus on splitting a URL string into its components, or on combining URL components into a URL string. ......
Read more >
net/url - Go Packages
ParseQuery parses the URL-encoded query string and returns a map listing the values specified for each key. ParseQuery always returns a non-nil map...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found