(params: Params)
| 645 | } |
| 646 | |
| 647 | export function generateQueryString(params: Params): string { |
| 648 | const pairs: string[] = []; |
| 649 | const keys: string[] = Object.keys(params); |
| 650 | keys.sort(); |
| 651 | for (let i = 0; i < keys.length; i++) { |
| 652 | const key = keys[i]; |
| 653 | const value = params[key]; |
| 654 | if (value == null) { |
| 655 | continue; |
| 656 | } |
| 657 | let pair = encodeURIComponent(key); |
| 658 | if (isArray(value)) { |
| 659 | for (let j = 0; j < value.length; j++) { |
| 660 | const arrayPair = `${key}[]=${encodeURIComponent(value[j])}`; |
| 661 | pairs.push(arrayPair); |
| 662 | } |
| 663 | } else { |
| 664 | pair += `=${encodeURIComponent(value as string)}`; |
| 665 | pairs.push(pair); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | if (pairs.length === 0) { |
| 670 | return ""; |
| 671 | } |
| 672 | |
| 673 | return `?${pairs.join("&")}`; |
| 674 | } |
| 675 | |
| 676 | export function parseQueryString(queryString: string): QueryParams { |
| 677 | const pairs = queryString.split("&"); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…