I want to detect if a requested URL contains query string or not. How can I do so?
You can directly use getQueryString() method
OR
You can check if your url has a query string or not by splitting it on "?" or finding index of the "?" character.
On splitting, your result array must have atleast length greater than 1 and if you take the index route, then the index must be greater than 0 since first character cant be a "?" assuming you will have correct url entered to check for query string.
Something like requestedUrl.indexOf("?") > 0
should do. Because query string parameters are passed by appending ? to the url and then name/value pairs follow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With