(input: Input)
| 157 | * @since 4.0.0 |
| 158 | */ |
| 159 | export const fromInput = (input: Input): UrlParams => { |
| 160 | if (isUrlParams(input)) { |
| 161 | return input |
| 162 | } |
| 163 | const parsed = fromInputNested(input) |
| 164 | const out: Array<[string, string]> = [] |
| 165 | for (let i = 0; i < parsed.length; i++) { |
| 166 | if (Array.isArray(parsed[i][0])) { |
| 167 | const [keys, value] = parsed[i] as [Array<string>, string] |
| 168 | out.push([`${keys[0]}[${keys.slice(1).join("][")}]`, value]) |
| 169 | } else { |
| 170 | out.push(parsed[i] as [string, string]) |
| 171 | } |
| 172 | } |
| 173 | return make(out) |
| 174 | } |
| 175 | |
| 176 | const fromInputNested = (input: Input): Array<[string | Array<string>, any]> => { |
| 177 | const entries = typeof (input as any)[Symbol.iterator] === "function" |
no test coverage detected