Skip to content

Instantly share code, notes, and snippets.

@Akiyamka
Created April 9, 2018 15:51
Show Gist options
  • Select an option

  • Save Akiyamka/91cbcbcb40fb3409f0ccd6f446a6a8d3 to your computer and use it in GitHub Desktop.

Select an option

Save Akiyamka/91cbcbcb40fb3409f0ccd6f446a6a8d3 to your computer and use it in GitHub Desktop.
createObjFromUrl(uriString){
if (uriString && typeof uriString === 'string' && uriString.includes('=')) {
uriString = uriString.split('&').map((item) => item.split('='));
let urlObject = {};
uriString.forEach((i) => { urlObject[i[0]] = i[1]; });
return urlObject;
} else {
console.warn('Cannot parse that string: ' + uriString);
return {};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment