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

Function parseKeyValue

test/angular/1.3/angular.js:1126–1145  ·  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

1124 * @returns {Object.<string,boolean|Array>}
1125 */
1126function parseKeyValue(/**string*/keyValue) {
1127 var obj = {}, key_value, key;
1128 forEach((keyValue || "").split('&'), function(keyValue) {
1129 if (keyValue) {
1130 key_value = keyValue.replace(/\+/g,'%20').split('=');
1131 key = tryDecodeURIComponent(key_value[0]);
1132 if (isDefined(key)) {
1133 var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
1134 if (!hasOwnProperty.call(obj, key)) {
1135 obj[key] = val;
1136 } else if (isArray(obj[key])) {
1137 obj[key].push(val);
1138 } else {
1139 obj[key] = [obj[key],val];
1140 }
1141 }
1142 }
1143 });
1144 return obj;
1145}
1146
1147function toKeyValue(obj) {
1148 var parts = [];

Callers 2

parseAppUrlFunction · 0.70
angular.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected