Created
April 27, 2019 19:57
-
-
Save gilbarbara/76f980f6c4a9761e2c38b1261682bdcf to your computer and use it in GitHub Desktop.
Validate Spotify URIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateURI(input: string): boolean { | |
let isValid = false; | |
if (input && input.indexOf(':') > -1) { | |
const [key, type, id] = input.split(':'); | |
if (key && type && id && id.length === 22) { | |
isValid = true; | |
} | |
} | |
return isValid; | |
} | |
validateURI('spotify:album:7KvKuWUxxNPEU80c4i5AQk') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment