Skip to content

Instantly share code, notes, and snippets.

@akinozgen
Last active August 13, 2020 12:37
Show Gist options
  • Save akinozgen/5ddd12c969f8df86be5dcccd481af6c9 to your computer and use it in GitHub Desktop.
Save akinozgen/5ddd12c969f8df86be5dcccd481af6c9 to your computer and use it in GitHub Desktop.
function _g() {
vars = {};
(window.location.href.split('?').length>1?window.location.href.split('?')[1]:'').split('&').forEach(_ => {
p=_.split('=');
vars[`${p[0]}`]=p[1].split(',').length>1?p[1].split(','):p[1];
});
return vars;
}
function unset(a,b) {
g = _g();
g[b] = (Array.isArray(g)?g:[g])[b].map(_=>{return decodeURIComponent(_);}).filter(x=>x!=a);
u = Object.keys(g).map(_=>`${_}=${Array.isArray(g[_]?g[_].join(','):g[_])}`).join(',');
window.location = `${window.location.href.split('?')[0]}?${uri}`;
} // unset('İmex', 'marka')
function unset(a){
var getVars = _get();
getVars['marka'] = getVars.marka.map(_=>{return decodeURIComponent(_)}).filter(marka => marka != a);
var uri = Object.keys(getVars).map((_) => `${_}=${Array.isArray(getVars[_]) ? getVars[_].join(','):getVars[_]}`).join('&');
window.location = `${window.location.href.split('?')[0]}?${uri}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment