spotify-uri
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -27,3 +27,3 @@ | ||
if (parsed.starred) { | ||
// "starred" playlist | ||
// user's "starred" playlist | ||
return base + '/user/' + encode(parsed.user) + '/starred'; | ||
@@ -30,0 +30,0 @@ } else if ('playlist' == parsed.type) { |
@@ -23,5 +23,20 @@ | ||
function formatURI (parsed) { | ||
if ('search' == parsed.type) { | ||
if ('string' == typeof parsed) parsed = parse(parsed); | ||
if (parsed.starred) { | ||
// 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; | ||
} else if ('local' == parsed.type) { | ||
// "local" file | ||
return 'spotify:local:' + encode(parsed.artist) + | ||
':' + encode(parsed.album) + | ||
':' + encode(parsed.track) + | ||
':' + parsed.seconds; | ||
} else if ('search' == parsed.type) { | ||
// "search" query | ||
return 'spotify:search:' + encode(parsed.query); | ||
} else { | ||
// artist, album, track | ||
return 'spotify:' + parsed.type + ':' + parsed.id; | ||
@@ -28,0 +43,0 @@ } |
@@ -0,1 +1,8 @@ | ||
0.1.1 / 2013-09-13 | ||
================== | ||
- formatURI: fix the "starred" playlist case (#1) | ||
- formatURI: fix the user "playlist" case (#1) | ||
- formatURI: fix the "local" file case (#1) | ||
0.1.0 / 2013-06-01 | ||
@@ -2,0 +9,0 @@ ================== |
{ | ||
"name": "spotify-uri", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Parse the various Spotify URI formats into Objects and back", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -52,2 +52,8 @@ | ||
}); | ||
it('should parse "user" URLs', function () { | ||
var url = 'http://open.spotify.com/user/tootallnate'; | ||
var obj = parse(url); | ||
assert('user' == obj.type); | ||
assert('tootallnate' == obj.id); | ||
}); | ||
}); | ||
@@ -108,3 +114,3 @@ | ||
}); | ||
it('should parse "lcoal" track URIs 2', function () { | ||
it('should parse "local" track URIs 2', function () { | ||
var uri = 'spotify:local:::a:6'; | ||
@@ -156,2 +162,23 @@ var obj = parse(uri); | ||
}); | ||
it('should format "starred" playlist open URLs', function () { | ||
var url = 'http://open.spotify.com/user/syknyk/starred'; | ||
var obj = parse(url); | ||
var expected = 'spotify:user:syknyk:starred'; | ||
var actual = formatURI(obj); | ||
assert(actual == expected); | ||
}); | ||
it('should parse "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 "local" file URIs', function () { | ||
var url = 'spotify:local:Flite%2c+Medium+Minus:YouTube:Find+What+You+Love:399'; | ||
var obj = parse(url); | ||
var expected = 'spotify:local:Flite%2C+Medium+Minus:YouTube:Find+What+You+Love:399'; | ||
var actual = formatURI(obj); | ||
assert(actual == expected); | ||
}); | ||
}); | ||
@@ -158,0 +185,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
116769
4469
0