diff --git a/src/parse.ts b/src/parse.ts index 8d6b8ea..469b2e7 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -90,5 +90,8 @@ function parseParts(uri: string, parts: string[]): ParsedSpotifyUri { if (parts[1] === 'show') { return new Show(uri, parts[2]); } + if (parts[1] === 'playlist') { + return new Playlist(uri, parts[2]); + } throw new TypeError(`Could not determine type for: ${uri}`); } diff --git a/test/test.js b/test/test.js index 2b5eb8c..938541c 100644 --- a/test/test.js +++ b/test/test.js @@ -95,6 +95,13 @@ describe('parse()', function () { assert.equal('track', obj.type) assert.equal('5oscsdDQ0NpjsTgpG4bI8S', obj.id) }) + it('should parse "playlist" URLs', function () { + let url = + 'https://embed.spotify.com/?uri=spotify:playlist:7arbVhvtYYaLYJefoRBSvU' + let obj = parse(url) + assert.equal('playlist', obj.type) + assert.equal('7arbVhvtYYaLYJefoRBSvU', obj.id) + }) }) describe('"open.spotify.com/embed" URLs (e.g. twitter embed)', function () { @@ -104,6 +111,12 @@ describe('parse()', function () { assert.equal('track', obj.type) assert.equal('5oscsdDQ0NpjsTgpG4bI8S', obj.id) }) + it('should parse "playlist" URLs', function () { + let url = 'https://open.spotify.com/embed/playlist/7arbVhvtYYaLYJefoRBSvU' + let obj = parse(url) + assert.equal('playlist', obj.type) + assert.equal('7arbVhvtYYaLYJefoRBSvU', obj.id) + }) }) describe('Spotify URIs', function () {