Strip off specific parameter from URL’s querystring

The safest “correct” method would be: Parse the url into an array with parse_url() Extract the query portion, decompose that into an array using parse_str() Delete the query parameters you want by unset() them from the array Rebuild the original url using http_build_query() Quick and dirty is to use a string search/replace and/or regex to … Read more

Decoding URI query string in Java

Use URLDecoder.decode(proxyRequestParam.replace(“+”, “%2B”), “UTF-8”) .replace(“%2B”, “+”) to simulate decodeURIComponent. Java’s URLDecoder decodes the plus sign to a space, which is not what you want, therefore you need the replace statements. Warning: the .replace(“%2B”, “+”) at the end will corrupt your data if the original (pre-x-www-form-urlencoded) contained that string, as @xehpuk pointed out.

Is array syntax using square brackets in URL query strings valid?

The answer is not simple. The following is extracted from section 3.2.2 of RFC 3986 : A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets (“[” and “]”). This is the only place where square bracket characters are allowed in … Read more

When to use query parameters versus matrix parameters?

The differences between Matrix parameters and Query Parameters are much more than just convention. The main differences are: urls with query params won’t have their response cached by intermediaries/proxies (at present) matrix parameters may appear anywhere in path calculating the relative uri is different query params are generally abused to add new verbs instead of … Read more

OK to skip slash before query string?

As a matter of modern spec, yes, it is permissible to skip the slash, contrary to what the accepted answer here claims. Although the accepted answer correctly quotes RFC 1738 (released over 20 years ago!), it wrongly claims that RFC 2396 (released in 1998) requires the slash, and neglects that both of those specs have … Read more

Enabling $_GET in codeigniter

Add the following library to your application libraries. It overrides the behaviour of the default Input library of clearing the $_GET array. It allows for a mixture of URI segments and query string. application/libraries/MY_Input.php class MY_Input extends CI_Input { function _sanitize_globals() { $this->allow_get_array = TRUE; parent::_sanitize_globals(); } } Its also necessary to modify some configuration … Read more

Detect change in query param react-router-dom v4.x and re-render component

React router from v4 onwards no longer gives you the query params in its location object. The reason being There are a number of popular packages that do query string parsing/stringifying slightly differently, and each of these differences might be the “correct” way for some users and “incorrect” for others. If React Router picked the … Read more