* Serializes into key-value pairs. Logic taken from * https://github.com/angular/angular.js/blob/864c7f0/src/Angular.js#L1409
(obj: {[k: string]: unknown})
| 289 | * https://github.com/angular/angular.js/blob/864c7f0/src/Angular.js#L1409 |
| 290 | */ |
| 291 | function toKeyValue(obj: {[k: string]: unknown}) { |
| 292 | const parts: unknown[] = []; |
| 293 | for (const key in obj) { |
| 294 | let value = obj[key]; |
| 295 | if (Array.isArray(value)) { |
| 296 | value.forEach((arrayValue) => { |
| 297 | parts.push( |
| 298 | encodeUriQuery(key, true) + |
| 299 | (arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)), |
| 300 | ); |
| 301 | }); |
| 302 | } else { |
| 303 | parts.push( |
| 304 | encodeUriQuery(key, true) + |
| 305 | (value === true ? '' : '=' + encodeUriQuery(value as any, true)), |
| 306 | ); |
| 307 | } |
| 308 | } |
| 309 | return parts.length ? parts.join('&') : ''; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * We need our custom method because encodeURIComponent is too aggressive and doesn't follow |
no test coverage detected
searching dependent graphs…