How to detect the requested url contains a query string?

hi everyone I want to determine if the requested url contains a query string or not how to do it?

+3
source share
2 answers

You can directly use the getQueryString () method

OR

You can check if your url has a query string or not by dividing it by "?" . or find the index "?" character.

When splitting, an array of results must have a length of at least more than 1, and if you take a pointer route, then the index must be greater than 0, since the first character cannot be "?" assuming you have the correct url entered to validate the query string.

+5

- requestedUrl.indexOf("?") > 0 . ? URL-, /.

+3

Source: https://habr.com/ru/post/1766621/


All Articles