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

Function parseKeyValue

lib/test/angular/1.8.0/angular.js:1548–1573  ·  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

1546 * @returns {Object.<string,boolean|Array>}
1547 */
1548function parseKeyValue(/**string*/keyValue) {
1549 var obj = {};
1550 forEach((keyValue || '').split('&'), function(keyValue) {
1551 var splitPoint, key, val;
1552 if (keyValue) {
1553 key = keyValue = keyValue.replace(/\+/g,'%20');
1554 splitPoint = keyValue.indexOf('=');
1555 if (splitPoint !== -1) {
1556 key = keyValue.substring(0, splitPoint);
1557 val = keyValue.substring(splitPoint + 1);
1558 }
1559 key = tryDecodeURIComponent(key);
1560 if (isDefined(key)) {
1561 val = isDefined(val) ? tryDecodeURIComponent(val) : true;
1562 if (!hasOwnProperty.call(obj, key)) {
1563 obj[key] = val;
1564 } else if (isArray(obj[key])) {
1565 obj[key].push(val);
1566 } else {
1567 obj[key] = [obj[key],val];
1568 }
1569 }
1570 }
1571 });
1572 return obj;
1573}
1574
1575function toKeyValue(obj) {
1576 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