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

Provide an alternative to Uri#queryParameters which returns the values as a list #2645

Closed
DartBot opened this issue Apr 18, 2012 · 16 comments
Closed
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 18, 2012

This issue was originally filed by @MarkBennett


What steps will reproduce the problem?

  1. Parse a Uri with a query string. (i.e. Uri.fromString("http://test.com/?age=32&name=Mark)
  2. Parse and transform uri query string manually.
  3. Be sad when I wasted extra lines.

What is the expected output? What do you see instead?

I expected to be able to call uri.params to access a Map of the params. This would also safely escape parameters, etc.

What version of the product are you using? On what operating system?

Version 0.1.0.201204121423, Build 6479
Dart SDK version 6478, Dartium version

Please provide any additional information below.

This issue arose as the result of a forum post...

https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/b4f94de2bb6456cb#

@madsager
Copy link
Contributor

Added Area-Library, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Apr 19, 2012

This comment was originally written by @seaneagan


I would suggest:

final Map<String, String> query;
final String queryString; // rename existing Uri#query

@DartBot
Copy link
Author

DartBot commented Apr 19, 2012

This comment was originally written by ladicek@gmail.com


Note that you can have more params of the same name in the query. It's the same case as HTTP headers -- when we get a [List]MultiMap, we should use that, until then, Map<String, List<String>>.

@DartBot
Copy link
Author

DartBot commented Apr 19, 2012

This comment was originally written by @MarkBennett


I agree that this will need MultiMap support or something similair in the future. Another option would be to collect multiple values into a List under the same key in the Map.

I'll take a look at how other frameworks handle this for comparison.

@DartBot
Copy link
Author

DartBot commented Apr 19, 2012

This comment was originally written by dr...@gmail.com


For things like OpenSearch patterns I think you would also need to test for multiple and empty query terms. Like in:

foo.org?qt1=p1,p2,p3&qt2=&qt3=p4

@peter-ahe-google
Copy link
Contributor

Sounds reasonable and something which can safely be added later.


Added this to the Later milestone.

@justinfagnani
Copy link
Contributor

We've seen a lot of code out there to parse query strings for Uri and Window.location. Since query strings are rarely useful without parsing, it'd be nice to get this solved sooner.

Rather than waiting on MultiMap, we can handle this like HttpHeaders and use [] to get the list of values and value() to get a single value.

Pete has a patch to add add query parsing to Location, but we're thinking it'd be much better on Uri, with a asUri() method on Location.


cc @blois.
Added Library-Uri label.

@justinfagnani
Copy link
Contributor

Marked this as blocking #6679.

@lrhn
Copy link
Member

lrhn commented Aug 22, 2013

cc @sgjesse.
Removed Type-Defect label.
Added Type-Enhancement label.

@sgjesse
Copy link
Contributor

sgjesse commented Aug 27, 2013

A Uri instance now has the getter queryParameters. It is a Map<String, String> and there is only one value for each name.

@andersjohnsen
Copy link

Changed the title to: "Make Uri#queryParameters return a MultiMap".

@lrhn
Copy link
Member

lrhn commented Apr 24, 2014

Removed Library-Uri label.
Added Library-Core label.

@kevmoo
Copy link
Member

kevmoo commented May 21, 2014

We cannot change the type of queryParamaters now, but we could imagine another member on Uri which provides access to individual values as a list.


Changed the title to: "Provide an alternative to Uri#queryParameters which returns the values as a list".

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Feb 29, 2016
@lrhn
Copy link
Member

lrhn commented Aug 11, 2017

Now also has Uri.queryParametersAll that returns Map<String,List<String>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants