MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / parseKeyValue

Function parseKeyValue

code/songhop/www/lib/angular/angular.js:1109–1128  ·  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

1107 * @returns {Object.<string,boolean|Array>}
1108 */
1109function parseKeyValue(/**string*/keyValue) {
1110 var obj = {}, key_value, key;
1111 forEach((keyValue || "").split('&'), function(keyValue) {
1112 if (keyValue) {
1113 key_value = keyValue.replace(/\+/g,'%20').split('=');
1114 key = tryDecodeURIComponent(key_value[0]);
1115 if (isDefined(key)) {
1116 var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
1117 if (!hasOwnProperty.call(obj, key)) {
1118 obj[key] = val;
1119 } else if (isArray(obj[key])) {
1120 obj[key].push(val);
1121 } else {
1122 obj[key] = [obj[key],val];
1123 }
1124 }
1125 }
1126 });
1127 return obj;
1128}
1129
1130function toKeyValue(obj) {
1131 var parts = [];

Callers 2

parseAppUrlFunction · 0.70
angular.jsFile · 0.70

Calls 3

forEachFunction · 0.70
tryDecodeURIComponentFunction · 0.70
isDefinedFunction · 0.70

Tested by

no test coverage detected