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

Ability to remove a specific query parameter #1010

Open
1 task done
SamStephens opened this issue Apr 16, 2024 · 0 comments
Open
1 task done

Ability to remove a specific query parameter #1010

SamStephens opened this issue Apr 16, 2024 · 0 comments

Comments

@SamStephens
Copy link

SamStephens commented Apr 16, 2024

Is your feature request related to a problem?

I'd like to be able to remove a specific query parameter. Given an URL like https://domain-name.com/path?param1=value1&param2=value2&param3=value3, I'd like to be able to derive an URL without the param2 query parameter, https://domain-name.com/path?param1=value1&param3=value3 in this case.__

Describe the solution you'd like

I'd like to be able to do this by providing None as the value of the parameter to update_query.

>>> URL('https://domain-name.com/path?param1=value1&param2=value2&param3=value3').update_query(param2=None)
URL('https://domain-name.com/path?param1=value1&param3=value3')

Describe alternatives you've considered

This could be done using a separate method, something like

>>> URL('https://domain-name.com/path?param1=value1&param2=value2&param3=value3').remove_query_param('param2')
URL('https://domain-name.com/path?param1=value1&param3=value3')

It's possible to do this by grabbing the URLs query dictionary, manipulating it, and replacing the entire query using with_query, but providing this behavior would give a cleaner way to express the operation.

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant