Could anybody have a suggestions on how to simply detect whether a string "looks like" a query string or not? For example, if I had a query string like this:
field1=value1&field2=&field3=value4
it would return true
.
Here's what I'm thinking should do the trick for what I need, but I am also open to any other suggestions as well as the below is very sketchy. Maybe there's even a function that returns false
when parsing an invalid query string?
function looks_like_querystring(source) {
return /=.*?&/g.test(source);
}
or
function looks_like_querystring(source) {
return source.indexOf('&') != -1 && source.indexOf('=') != -1;
}