Sha256: 25c44e0083b02380c79a6dd632691e59b5af9760240db6ded2c21980e9422ca6

Contents?: true

Size: 916 Bytes

Versions: 7

Compression:

Stored size: 916 Bytes

Contents

/*
---

script: String.js

name: String

description: Normalized query string methods with array empty index support

license: MIT-style license

extends: More/String.QueryString

...
*/

String.implement({
	parseQueryString: function(decodeKeys, decodeValues){
		var object = {};
		for (var pair, bits, pairs = this.split('&'), i = 0, j = pairs.length; i < j; i++) {
			pair = pairs[i].split('=');
			var name = pair[0], value = pair[1];
			if (decodeValues !== false && value != null) value = decodeURIComponent(value);
			if (decodeKeys !== false) name = decodeURIComponent(name);
			var keys = name.match(/([^\]\[]+|(\B)(?=\]))/g);
			for (var key, bit, path = object, k = 0, l = keys.length; (key = keys[k]) || k < l; k++) {
				if (k == l - 1) key ? (path[key] = value) : path.push(value);
				else path = (path[key] || (path[key] = path[key] = (keys[k + 1] == "") ? [] : {}))
			}
		}
  	return object;
	}
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/mootools-ext/Source/Types/String.js
lsd_rails-0.1.5 Packages/mootools-ext/Source/Types/String.js
lsd_rails-0.1.4 Packages/mootools-ext/Source/Types/String.js
lsd_rails-0.1.3 Packages/mootools-ext/Source/Types/String.js
lsd_rails-0.1.2 Packages/mootools-ext/Source/Types/String.js
lsd_rails-0.1.1 Packages/mootools-ext/Source/Types/String.js
lsd_rails-0.1 Packages/mootools-ext/Source/Types/String.js