From 89a5b07ad5e9231bd1af6c956001163553dddbcf Mon Sep 17 00:00:00 2001 From: Miraculous Owonubi Date: Sun, 23 Feb 2020 04:54:59 +0100 Subject: [PATCH 1/5] Fix non-user playlist URI formatting --- formatURI.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/formatURI.js b/formatURI.js index f4155da..ed294f6 100644 --- a/formatURI.js +++ b/formatURI.js @@ -24,8 +24,8 @@ function formatURI(parsed) { // user's "starred" playlist return 'spotify:user:' + encode(parsed.user) + ':starred'; } else if ('playlist' == parsed.type) { - // user "playlist" - return 'spotify:user:' + encode(parsed.user) + ':playlist:' + parsed.id; + // user or non-user "playlist" + return 'spotify:' + (parsed.user ? 'user:' + encode(parsed.user) : '') + 'playlist:' + parsed.id; } else if ('local' == parsed.type) { // "local" file return ( From 2b44b1614ef11b2489740009d5baa2aca79d2593 Mon Sep 17 00:00:00 2001 From: Miraclx Date: Sun, 23 Feb 2020 07:18:28 +0100 Subject: [PATCH 2/5] Fix open equivalent for playlist URI formatting --- formatOpenURL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formatOpenURL.js b/formatOpenURL.js index 014eebd..fd38d14 100644 --- a/formatOpenURL.js +++ b/formatOpenURL.js @@ -27,7 +27,7 @@ function formatOpenURL(parsed, base) { return base + '/user/' + encode(parsed.user) + '/starred'; } else if ('playlist' == parsed.type) { // user "playlist" - return base + '/user/' + encode(parsed.user) + '/playlist/' + parsed.id; + return base + (parsed.user ? '/user/' + encode(parsed.user) : '') + '/playlist/' + parsed.id; } else if ('local' == parsed.type) { // "local" file return ( From a2695f4ef5b7c89791edda977b5713d07247da7b Mon Sep 17 00:00:00 2001 From: Miraclx Date: Sun, 23 Feb 2020 07:39:21 +0100 Subject: [PATCH 3/5] Fix segmentation typo --- formatURI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formatURI.js b/formatURI.js index ed294f6..e86b940 100644 --- a/formatURI.js +++ b/formatURI.js @@ -25,7 +25,7 @@ function formatURI(parsed) { return 'spotify:user:' + encode(parsed.user) + ':starred'; } else if ('playlist' == parsed.type) { // user or non-user "playlist" - return 'spotify:' + (parsed.user ? 'user:' + encode(parsed.user) : '') + 'playlist:' + parsed.id; + return 'spotify' + (parsed.user ? ':user:' + encode(parsed.user) : '') + ':playlist:' + parsed.id; } else if ('local' == parsed.type) { // "local" file return ( From 02b9a3878343a3ef1a30a3099e7555595b27da4e Mon Sep 17 00:00:00 2001 From: Miraclx Date: Sun, 23 Feb 2020 07:40:52 +0100 Subject: [PATCH 4/5] test: public playlist formatting --- test/test.js | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index c53e669..d3cb5f1 100644 --- a/test/test.js +++ b/test/test.js @@ -18,7 +18,7 @@ describe('parse()', function() { assert('track' == obj.type); assert('10M2REwwztVxgr0szw7UwD' == obj.id); }); - it('should parse "playlist" URLs', function() { + it('should parse user "playlist" URLs', function() { var url = 'http://open.spotify.com/user/tootallnate/playlist/0Lt5S4hGarhtZmtz7BNTeX'; var obj = parse(url); @@ -26,6 +26,13 @@ describe('parse()', function() { assert('tootallnate' == obj.user); assert('0Lt5S4hGarhtZmtz7BNTeX' == obj.id); }); + it('should parse public "playlist" URLs', function() { + var url = + 'https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M'; + var obj = parse(url); + assert('playlist' == obj.type); + assert('37i9dQZF1DXcBWIGoYBM5M' == obj.id); + }); it('should parse "local" URLs', function() { var url = 'http://open.spotify.com/local/Yasunori+Mitsuda/Chrono+Trigger+OST/A+Shot+of+Crisis/161'; @@ -110,7 +117,7 @@ describe('parse()', function() { assert('track' == obj.type); assert('5CMjjywI0eZMixPeqNd75R' == obj.id); }); - it('should parse "playlist" URIs', function() { + it('should parse user "playlist" URIs', function() { var uri = 'spotify:user:daftpunkofficial:playlist:6jP6EcvAwqNksccDkIe6hX'; var obj = parse(uri); @@ -118,6 +125,13 @@ describe('parse()', function() { assert('daftpunkofficial' == obj.user); assert('6jP6EcvAwqNksccDkIe6hX' == obj.id); }); + it('should parse public "playlist" URIs', function() { + var uri = + 'spotify:playlist:37i9dQZF1DX4JAvHpjipBk'; + var obj = parse(uri); + assert('playlist' == obj.type); + assert('37i9dQZF1DX4JAvHpjipBk' == obj.id); + }); it('should parse "local" track URIs', function() { var uri = 'spotify:local:Yasunori+Mitsuda:Chrono+Trigger+OST:A+Shot+of+Crisis:161'; @@ -193,13 +207,20 @@ describe('formatURI()', function() { var actual = formatURI(obj); assert(actual == expected); }); - it('should parse "playlist" URIs', function() { + it('should parse user "playlist" URIs', function() { var url = 'spotify:user:syknyk:playlist:0Idyatn0m08Y48tiOovNd9'; var obj = parse(url); var expected = 'spotify:user:syknyk:playlist:0Idyatn0m08Y48tiOovNd9'; var actual = formatURI(obj); assert(actual == expected); }); + it('should parse public "playlist" URIs', function() { + var url = 'spotify:playlist:37i9dQZF1DWUa8ZRTfalHk'; + var obj = parse(url); + var expected = 'spotify:playlist:37i9dQZF1DWUa8ZRTfalHk'; + var actual = formatURI(obj); + assert(actual == expected); + }); it('should parse "local" file URIs', function() { var url = 'spotify:local:Flite%2c+Medium+Minus:YouTube:Find+What+You+Love:399'; @@ -233,7 +254,7 @@ describe('formatOpenURL()', function() { var actual = formatOpenURL(obj); assert(actual == expected); }); - it('should format "playlist" URIs', function() { + it('should format user "playlist" URIs', function() { var uri = 'spotify:user:daftpunkofficial:playlist:6jP6EcvAwqNksccDkIe6hX'; var obj = parse(uri); @@ -242,6 +263,15 @@ describe('formatOpenURL()', function() { var actual = formatOpenURL(obj); assert(actual == expected); }); + it('should format public "playlist" URIs', function() { + var uri = + 'spotify:playlist:37i9dQZF1DXaPCIWxzZwR1'; + var obj = parse(uri); + var expected = + 'http://open.spotify.com/playlist/37i9dQZF1DXaPCIWxzZwR1'; + var actual = formatOpenURL(obj); + assert(actual == expected); + }); it('should format "starred" playlist URIs', function() { var uri = 'spotify:user:tootallnate:starred'; var obj = parse(uri); From 15546c05a460a0e58fed0547013f1ca97a8fffab Mon Sep 17 00:00:00 2001 From: Miraclx Date: Sun, 23 Feb 2020 07:43:24 +0100 Subject: [PATCH 5/5] ignore package-lock-json --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 73eef81..fa53161 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ /build /yarn.lock /components + +package-lock.json