← Back to challenges

Spotify URL to URI Converter

JavaScriptHardregexstrings

Instructions

Write a function that converts Spotify URL's to URI's and vice versa.

Examples

spotiConv(`https://open.spotify.com/artist/4IZLJdhHCqAvT4pjn8TLH5`) ➞ `spotify:artist:4IZLJdhHCqAvT4pjn8TLH5`

spotiConv(`spotify:album:3W7DQfYXpm7N4R5mv4lg3t`) ➞ `https://open.spotify.com/album/3W7DQfYXpm7N4R5mv4lg3t`

spotiConv(`https://open.spotify.com/track/0bYg9bo50gSsH3LtXe2SQn`) ➞ `spotify:track:0bYg9bo50gSsH3LtXe2SQn`

Notes

Check the examples for the formatting.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.