Created
November 16, 2018 16:09
-
-
Save jeandcr/e6adf084a3970a92e3a3c834a48d03e1 to your computer and use it in GitHub Desktop.
Revisions
-
jeandcr created this gist
Nov 16, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /** * * Returns a URL query parameter by it's key. * eg. You have a URL: http://host.com/some/path?uniquekey=value * The function call qs('uniquekey') returns 'value' * * @param key string * @return string * */ function qs(key) { key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)")); return match && decodeURIComponent(match[1].replace(/\+/g, " ")); }