Deviopath › TypeScript

Parse a Query String

Medium · Records & Maps

Write parseQuery(query: string): Record<string, string> that turns "a=1&b=2" into { a: "1", b: "2" }.

- Parts are separated by &. Skip empty parts.

- Split each part at the FIRST =. A part without = gets the value "".

- If a key appears twice, the later value wins.

Next: Merge a Readonly Config