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

Function parseKeyValue

lib/test/angular/1.6.7/angular.js:1540–1565  ·  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

1538 * @returns {Object.<string,boolean|Array>}
1539 */
1540function parseKeyValue(/**string*/keyValue) {
1541 var obj = {};
1542 forEach((keyValue || '').split('&'), function(keyValue) {
1543 var splitPoint, key, val;
1544 if (keyValue) {
1545 key = keyValue = keyValue.replace(/\+/g,'%20');
1546 splitPoint = keyValue.indexOf('=');
1547 if (splitPoint !== -1) {
1548 key = keyValue.substring(0, splitPoint);
1549 val = keyValue.substring(splitPoint + 1);
1550 }
1551 key = tryDecodeURIComponent(key);
1552 if (isDefined(key)) {
1553 val = isDefined(val) ? tryDecodeURIComponent(val) : true;
1554 if (!hasOwnProperty.call(obj, key)) {
1555 obj[key] = val;
1556 } else if (isArray(obj[key])) {
1557 obj[key].push(val);
1558 } else {
1559 obj[key] = [obj[key],val];
1560 }
1561 }
1562 }
1563 });
1564 return obj;
1565}
1566
1567function toKeyValue(obj) {
1568 var parts = [];

Callers 3

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