MCPcopy
hub / github.com/binux/qiandao / parseKeyValue

Function parseKeyValue

web/static/components/angularjs/angular.js:1199–1218  ·  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

1197 * @returns {Object.<string,boolean|Array>}
1198 */
1199function parseKeyValue(/**string*/keyValue) {
1200 var obj = {}, key_value, key;
1201 forEach((keyValue || "").split('&'), function(keyValue) {
1202 if ( keyValue ) {
1203 key_value = keyValue.replace(/\+/g,'%20').split('=');
1204 key = tryDecodeURIComponent(key_value[0]);
1205 if ( isDefined(key) ) {
1206 var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
1207 if (!hasOwnProperty.call(obj, key)) {
1208 obj[key] = val;
1209 } else if(isArray(obj[key])) {
1210 obj[key].push(val);
1211 } else {
1212 obj[key] = [obj[key],val];
1213 }
1214 }
1215 }
1216 });
1217 return obj;
1218}
1219
1220function toKeyValue(obj) {
1221 var parts = [];

Callers 2

parseAppUrlFunction · 0.85
angular.jsFile · 0.85

Calls 4

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

Tested by

no test coverage detected