ghoullier
2/7/2013 - 7:15 AM

Provide Simple Class to QueryString

Provide Simple Class to QueryString

(function(global) {
  var QueryString = (function() {
		function Class(){
			if (this instanceof Class) {
			
			} else {
				throw new Error("Illegal constructor");
			}
		};
		Class.get = function(/*String*/name) {
			name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
			var pattern = "[\\?&]" + name + "=([^&#]*)",
					regex = new RegExp(pattern),
					results = regex.exec(window.location.search);
			return (results === null) ? "" : global.decodeURIComponent(results[1].replace(/\+/g, " "));
		};
		return Class;
	}());
	global.QueryString = QueryString;
}(this));