You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While according to RFC spec, query params are case-sensitive, there should be a method allowing for case-insensitive search for query params when just checking for existence.
var uri = "http://www.acme.com?test=1"
uri.hasQuery("TEST"); //returns false
New function signature would look like this:
URI.hasQueryParameter = function (data, name, caseSensitive) {
//force undefined params
var param3, param4;
return URI.hasQuery(data, name, param3, param4, caseSensitive);
}
...with new param to main hasQuery method:
URI.hasQuery = function (data, name, value, withinArray, caseSensitive) {
// SNIP...
switch (getType(value)) {
case 'Undefined':
// true if exists (but may be empty)
return !caseSensitive ? name in data : return data[name] !== undefined;
// SNIP...
}
uri.hasQueryParameter("TEST", false); //returns true
uri.hasQueryParameter("TEST", true); //returns false
This approach maintains backwards compatibility without ugly calls from client script.
The text was updated successfully, but these errors were encountered:
Not a problem with the data... the key is the problem. I can see the key often being case-insensitive in many systems
Realized I can use RegExp in the latest URI.js for hasQuery and removeQuery... I can pass a regex like /TEST/i to get what I want.
In the version we were on, RegEx option did not yet exist for the name property (only the value). That works for hasQuery and removeQuery... doesn't really work for getting the value of the param though.
While according to RFC spec, query params are case-sensitive, there should be a method allowing for case-insensitive search for query params when just checking for existence.
New function signature would look like this:
...with new param to main hasQuery method:
This approach maintains backwards compatibility without ugly calls from client script.
The text was updated successfully, but these errors were encountered: