MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / parseKeyValue

Function parseKeyValue

lib/test/angular/1.4.3/angular.js:1302–1321  ·  view source on GitHub ↗

* Parses an escaped url query string into key-value pairs. * @returns {Object. }

(/**string*/keyValue)

Source from the content-addressed store, hash-verified

1300 * @returns {Object.<string,boolean|Array>}
1301 */
1302function parseKeyValue(/**string*/keyValue) {
1303 var obj = {}, key_value, key;
1304 forEach((keyValue || "").split('&'), function(keyValue) {
1305 if (keyValue) {
1306 key_value = keyValue.replace(/\+/g,'%20').split('=');
1307 key = tryDecodeURIComponent(key_value[0]);
1308 if (isDefined(key)) {
1309 var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
1310 if (!hasOwnProperty.call(obj, key)) {
1311 obj[key] = val;
1312 } else if (isArray(obj[key])) {
1313 obj[key].push(val);
1314 } else {
1315 obj[key] = [obj[key],val];
1316 }
1317 }
1318 }
1319 });
1320 return obj;
1321}
1322
1323function toKeyValue(obj) {
1324 var parts = [];

Callers 2

parseAppUrlFunction · 0.70
angular.jsFile · 0.70

Calls 4

forEachFunction · 0.70
tryDecodeURIComponentFunction · 0.70
isDefinedFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected