Skip to content

Instantly share code, notes, and snippets.

@taverasmisael
Last active September 22, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taverasmisael/4369a237970b296c77b0f9dd8e3cf0c8 to your computer and use it in GitHub Desktop.
Save taverasmisael/4369a237970b296c77b0f9dd8e3cf0c8 to your computer and use it in GitHub Desktop.
A helper using Ramda to transform a URLSearch to an Object
const {prop, split, fromPairs, fromPairs, map, compose, tail} = R // from RamdaJS
export const URLSearchToObject = compose(
fromPairs,
map(split('=')),
compose(
split('&'),
tail
)
)
// Usage
URLSearchToObject('?some=param&any=other') // => ({some: 'param', any: 'other'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment