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

URL.add supporting a list of values #182

Open
ddormer opened this issue May 23, 2023 · 0 comments
Open

URL.add supporting a list of values #182

ddormer opened this issue May 23, 2023 · 0 comments

Comments

@ddormer
Copy link

ddormer commented May 23, 2023

I occasionally find myself making multiple URL.add method calls in a loop to add a list of values to the same query parameter name. If I'm not alone, perhaps it would be nice to add support for passing a list of values to URL.add?

For example:

>>> # This currently returns a list of values.
>>> values = URL.from_text('?foo=1&foo=2').get('foo')
>>> values
['1', '2']
>>> # This is currently a TypeError
>>> URL.add('foo', values)
URL.from_text('?foo=1&foo=2')

While looping over a single list and making multiple add calls isn't much effort, when working with a dictionary of parameters that I'd like to build a URL out of, and the dictionary may or may not have a list of values for some of the keys, I find the code needed to check each dictionary value and loop over the lists a bit messy.

Edit: I'm willing to put work into a PR for the feature, if the feature is considered a good addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant