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

Function parseKeyValue

test/angular/1.2/angular.js:1206–1225  ·  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

1204 * @returns {Object.<string,boolean|Array>}
1205 */
1206function parseKeyValue(/**string*/keyValue) {
1207 var obj = {}, key_value, key;
1208 forEach((keyValue || "").split('&'), function(keyValue) {
1209 if ( keyValue ) {
1210 key_value = keyValue.replace(/\+/g,'%20').split('=');
1211 key = tryDecodeURIComponent(key_value[0]);
1212 if ( isDefined(key) ) {
1213 var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
1214 if (!hasOwnProperty.call(obj, key)) {
1215 obj[key] = val;
1216 } else if(isArray(obj[key])) {
1217 obj[key].push(val);
1218 } else {
1219 obj[key] = [obj[key],val];
1220 }
1221 }
1222 }
1223 });
1224 return obj;
1225}
1226
1227function toKeyValue(obj) {
1228 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