urlParsed doesn't support repeated search params
See original GitHub issueWhen 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:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.This is not really the case when you use checkboxes, as every checkbox will have the same query parameter.