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

Add case insensitive (query) param map (CaseInsensitiveParamMap) #55968

Open
rklec opened this issue May 21, 2024 · 0 comments
Open

Add case insensitive (query) param map (CaseInsensitiveParamMap) #55968

rklec opened this issue May 21, 2024 · 0 comments
Labels
area: router feature Issue that requests a new feature freq1: low P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Milestone

Comments

@rklec
Copy link

rklec commented May 21, 2024

Which @angular/* package(s) are relevant/related to the feature request?

router

Description

A very common issue seems to be to get a (query) parameter in a case insensitive way.

wrong hypothesis

More back-story: This seems to happen, because this.router.navigate also seems to lower-case all query parameters you pass it in:

    const queryParams = {LoGiN: "abc"} as Params;
    console.info('Triggering filter with data:', queryParams);

    this.router.navigate(
      [],
      {
        relativeTo: this.activatedRoute,
        queryParams: queryParams
      }
    );    

This results in .../?login=abc on the current page. (I may create a new bug for this, if that is not intentional.)
Anyway, there may be other reasons to ignore the casing. And I tried...

E.g. I want to use query parameters for filtering data with specific terms in my application, so I can do this:

    this.activatedRoute.queryParams
      .subscribe(params => {
          const paramMap = convertToParamMap(params);

          const filter = {
            login: paramMap.get("login")
            // ...
          };
          
          // ...
        });            

In contrast to using params (Params) directly, it does not throw,

Now, if I pass ...?login=blaBlub this works, but if I do pass ...?Login=blaBlub it does not as the usual convertToParamMap/param map is case-sensitive, apparently.

Proposed solution

Full credit goes to Bradley Carey, who has developed a CaseInsensitiveParamMap including test cases etc.

Maybe it can just be integrated in some way or another into Angular?

Alternatives considered

Any similar solution could also be developed? Like adding a flag to the existing ParamsAsMap :

class ParamsAsMap implements ParamMap {

Also, it should probably support localization i.e. use toLocaleLowerCase or the Angular equivalent.

@atscott atscott added feature Issue that requests a new feature freq1: low P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels May 21, 2024
@ngbot ngbot bot added this to the Backlog milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: router feature Issue that requests a new feature freq1: low P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

3 participants