(query: string | URLSearchParams, keys?: string[])
| 63 | } |
| 64 | |
| 65 | function filterQueryKeys(query: string | URLSearchParams, keys?: string[]) { |
| 66 | const source = new URLSearchParams(query) |
| 67 | if (!keys || keys.length === 0) { |
| 68 | return source |
| 69 | } |
| 70 | const destination = new URLSearchParams() |
| 71 | for (const [key, value] of source.entries()) { |
| 72 | if (keys.includes(key)) { |
| 73 | destination.append(key, value) |
| 74 | } |
| 75 | } |
| 76 | return destination |
| 77 | } |