Query strings should be modeled as a multimap
See original GitHub issueAs indicated by the Wikipedia page Query string:
While there is no definitive standard, most web frameworks allow multiple values to be associated with a single field (e.g.
field1=value1&field1=value2&field2=value3
).
And indeed, many web frameworks I have used adopt this approach:
- Django: https://docs.djangoproject.com/en/3.2/ref/request-response/#django.http.QueryDict.getlist
- Starlette: https://www.starlette.io/requests/#query-parameters
- nodejs/querystring: https://nodejs.org/api/querystring.html#querystringparsestr-sep-eq-options
Therefore, I suggest itty-router
follow the same convention.
Currently, itty-router
models query strings as a Obj
:
where Obj
is actually a map from some string to some string:
I suggest introducing MultiObj
as the data model of query strings:
export type MultiObj = {
[propName: string]: string | Array<string>
}
I’d like to help if you @kwhitley are interested in this 😃
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Use Multimap instead of Map for sending parameters for Rest ...
1 a Map and Set< String > should do the job: com.ning.http.client.FluentStringsMap map = new com.ning.http.client.
Read more >Use MultiMap instead of HashMap for the parsed query params ...
Use multimap for the parsed query params instead of HashMap<String, Vec<String>> . Mulitmap is basically a thin wrapper around HashMap<T, Vec<T>> , but...
Read more >How to make multiple values per key in a Java map possible ...
Need to add multiple values to a key in a Java HashMap but can't figure out ... Multimap<String, String> map = ArrayListMultimap.create(); ...
Read more >Multiple Mapping - Dapper .NET - Medium
With Multiple Mapping we can easily handle mapping of object between our database and our object model that supports 1:1 relationships between ...
Read more >How to Use Query Strings and Parameters for Marketers
A key-value pair can be separated into a key, a value, and a separator. The separator is the equals sign ( = )....
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
Would it not be better to stick to web standard APIs, since CF Workers/itty already rely on
Request
,Response
etc? TheURLSearchParams
interface is specifically designed for this:This will be included in the next major release 😃