Created
January 15, 2019 11:33
-
-
Save 2yk/f17b94f65b352ae277c2d2f7b9ff3530 to your computer and use it in GitHub Desktop.
Following function will convert search string to object
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 characters
# Following function will convert search string to object | |
<script> | |
!function(){"use strict";Array.isArray||(Array.isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)});var r={get:function(){var r=window.location.search,t={};return""===r?t:(r=r.slice(1),r=r.split("&"),r.map(function(r){var i,o;r=r.split("="),i=r[0],o=r[1],t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(o)):t[i]=o}),t)}};if(window){if(window.qs)throw new Error("Error bootstrapping qs: window.qs already set.");window.qs=r}}(); | |
const obj = window.qs.get(search); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment