MCPcopy
hub / github.com/angular-ui/ui-grid / parseKeyValue

Function parseKeyValue

lib/test/angular/1.7.0/angular.js:1508–1533  ·  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

1506 * @returns {Object.<string,boolean|Array>}
1507 */
1508function parseKeyValue(/**string*/keyValue) {
1509 var obj = {};
1510 forEach((keyValue || '').split('&'), function(keyValue) {
1511 var splitPoint, key, val;
1512 if (keyValue) {
1513 key = keyValue = keyValue.replace(/\+/g,'%20');
1514 splitPoint = keyValue.indexOf('=');
1515 if (splitPoint !== -1) {
1516 key = keyValue.substring(0, splitPoint);
1517 val = keyValue.substring(splitPoint + 1);
1518 }
1519 key = tryDecodeURIComponent(key);
1520 if (isDefined(key)) {
1521 val = isDefined(val) ? tryDecodeURIComponent(val) : true;
1522 if (!hasOwnProperty.call(obj, key)) {
1523 obj[key] = val;
1524 } else if (isArray(obj[key])) {
1525 obj[key].push(val);
1526 } else {
1527 obj[key] = [obj[key],val];
1528 }
1529 }
1530 }
1531 });
1532 return obj;
1533}
1534
1535function toKeyValue(obj) {
1536 var parts = [];

Callers 3

parseAppUrlFunction · 0.70
angular.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected