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.