jsUri icon indicating copy to clipboard operation
jsUri copied to clipboard

"getQueryParamValue" is case sensitive

Open tung-dang opened this issue 10 years ago • 7 comments

Could getQueryParamValue ignore case sensitive? So these will return the same result:

uri.getQueryParamValue("productId")
uri.getQueryParamValue("ProductId")
uri.getQueryParamValue("productid")
uri.getQueryParamValue("PRODUCTID")

tung-dang avatar Dec 03 '15 07:12 tung-dang

What sort of environment are you working in that has case-insensitive URL params?

derek-watson avatar Dec 21 '15 14:12 derek-watson

This is an issue for me as well...

I have code like this, looking for 'iscloud' querystring: uri.getQueryParamValue('iscloud') Because I know admins using my site will type in something like this: blaurldemo?isCloud=true

Now users of my website have to get the casing right or my code doesn't find the param.

Right now, it's a bug and I have to tell these particular users to use lower case please. I think case sensitivity is wrong and unnecessary in a query string library, when searching for parameters, do you agree?

PandaWood avatar Oct 12 '16 00:10 PandaWood

@derek-watson Would you accept pull request for this? I'm thinking adding a boolean argument will make sense.

faridnsh avatar Feb 05 '17 08:02 faridnsh

@alFReD-NSH do you have a fork with the necessary change... I would like to go there.

PandaWood avatar Feb 05 '17 09:02 PandaWood

@derek-watson , I made a pull request #63. I appreciate if you could have a look and tell me what you think.

faridnsh avatar Feb 07 '17 05:02 faridnsh

And this is my pull request #64 - sorry to compete with #63 but I have a few less calls to toLowerCase() as I store the lower case instance of the string and then the == comparison works without calling it explicitly every time

PandaWood avatar May 11 '17 04:05 PandaWood

Please ignore my PR #64 - it has a bug in itself. I was over zealous in applying toLowerCase and the results returned are actually converted to all lower case as a result - which is not desirable either. I should add some unit tests to cover it and fix it but #63 looks like a good alternative

PandaWood avatar Apr 04 '19 04:04 PandaWood