MCPcopy
hub / github.com/jquery/esprima / parseKeyValue

Function parseKeyValue

test/3rdparty/angular-1.2.5.js:1096–1115  ·  view source on GitHub ↗

* Parses an escaped url query string into key-value pairs. * @returns Object.<(string|boolean)>

(/**string*/keyValue)

Source from the content-addressed store, hash-verified

1094 * @returns Object.<(string|boolean)>
1095 */
1096function parseKeyValue(/**string*/keyValue) {
1097 var obj = {}, key_value, key;
1098 forEach((keyValue || "").split('&'), function(keyValue){
1099 if ( keyValue ) {
1100 key_value = keyValue.split('=');
1101 key = tryDecodeURIComponent(key_value[0]);
1102 if ( isDefined(key) ) {
1103 var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
1104 if (!obj[key]) {
1105 obj[key] = val;
1106 } else if(isArray(obj[key])) {
1107 obj[key].push(val);
1108 } else {
1109 obj[key] = [obj[key],val];
1110 }
1111 }
1112 }
1113 });
1114 return obj;
1115}
1116
1117function toKeyValue(obj) {
1118 var parts = [];

Callers 2

parseAppUrlFunction · 0.85
angular-1.2.5.jsFile · 0.85

Calls 5

tryDecodeURIComponentFunction · 0.85
isDefinedFunction · 0.85
isArrayFunction · 0.85
pushMethod · 0.80
forEachFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…