Skip to content

Instantly share code, notes, and snippets.

@imcodetolive
Created September 4, 2014 17:45
Show Gist options
  • Save imcodetolive/e161103b158109812883 to your computer and use it in GitHub Desktop.
Save imcodetolive/e161103b158109812883 to your computer and use it in GitHub Desktop.
Convert URL parameters to a javascript object
define(function(){
"use strict";
var parseURLParams;
parseURLParams = function(str){
var obj;
obj = {};
if (!str) return obj;
str.replace(/([^=&]+)=([^&]*)/g, function(m, key, value){
obj[key] = (obj[key] ? obj[key] + "," : "") + value;
});
return obj;
};
return parseURLParams;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment