Skip to content

Instantly share code, notes, and snippets.

@2yk
Created January 15, 2019 11:33
Show Gist options
  • Save 2yk/f17b94f65b352ae277c2d2f7b9ff3530 to your computer and use it in GitHub Desktop.
Save 2yk/f17b94f65b352ae277c2d2f7b9ff3530 to your computer and use it in GitHub Desktop.
Following function will convert search string to object
# 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