Skip to content

Instantly share code, notes, and snippets.

@gilbarbara
Created April 27, 2019 19:57
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 gilbarbara/76f980f6c4a9761e2c38b1261682bdcf to your computer and use it in GitHub Desktop.
Save gilbarbara/76f980f6c4a9761e2c38b1261682bdcf to your computer and use it in GitHub Desktop.
Validate Spotify URIs
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