dotnet / dotnet/aspnetcore

Efficient removing of QueryString parameters

Open
#23,971 7 comments 1 reaction 0 assignees View on GitHub
affected-very-few area-networking enhancement feature-yarp severity-nice-to-have
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is your feature request related to a problem? Please describe.
I'm currently working on pull request Microsoft/reverse-proxy#301 for [YARP](https://github.com/Microsoft/reverse-proxy) to add support for transforming query parameters on the incoming request to downstream services. One thing that seems useful is to allow YARP to remove query parameters on the incoming request when they flow to the downstream by configuring a transformation. Currently this involves parsing the entire query string into a `Dictionary` using `QueryHelpers.Parse()`, removing the parameter we want and then using the `QueryBuilder` class to put it all back into a `QueryString` instance.

This feels a little bit wasteful in terms of performance since we're allocating a dictionary and doing a whole bunch of string parsing, only to remove a single query parameter.

### Describe the solution you'd like
Since the `QueryString` class already has an `Add` method it makes sense to add a `Remove` (or `Delete` if that's more appropriate) method to the `QueryString` that strips a query parameter from the query string in the most efficient way and returns a new `QueryString`.

### Additional context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.