Skip to content

URL.add supporting a list of values #182

@ddormer

Description

@ddormer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions