Skip to content

Instantly share code, notes, and snippets.

@ruizfrontend
Last active August 9, 2017 08:46
Show Gist options
  • Save ruizfrontend/ddd9ad7f24ef6df1f393b67d2e9899a4 to your computer and use it in GitHub Desktop.
Save ruizfrontend/ddd9ad7f24ef6df1f393b67d2e9899a4 to your computer and use it in GitHub Desktop.
CSV format URL parameters
module.exports = url => url
.split('?')[1]
.split('&')
.map(function(f){ return f.split('=')[0] + ',' + f.split('=')[1]; })
.join('\n');
@ruizfrontend
Copy link
Author

Process url string and return a CSV formatted list of the parameters.

Example:

urlParametersToCsv("http://expample.com?parameter1=value1&parameter2=value2")`

will return

parameter1,value1
parameter2,value2

Note: If the url don't have parameters will throw an exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment