Skip to content

Commit b9692b6

Browse files
committed
improved spotify
1 parent 9738f40 commit b9692b6

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/UrlRedirect.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class UrlRedirect
1111
'google' => 'https?://www.google.com/url*',
1212
'googleTranslator' => 'https?://translate.google.com/translate*',
1313
'hashBang' => '*#!*',
14+
'spotify' => 'https://play.spotify.com/*',
1415
];
1516

1617
/**
@@ -80,4 +81,16 @@ protected static function hashBang(Url $url)
8081

8182
return $url->getUrl();
8283
}
84+
85+
/**
86+
* Redirect the player of spotify.
87+
*
88+
* @param Url $url
89+
*
90+
* @return string
91+
*/
92+
protected static function spotify(Url $url)
93+
{
94+
return $url->withHost('open.spotify.com')->getUrl();
95+
}
8396
}

tests/SpotifyTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@
22

33
class SpotifyTest extends TestCaseBase
44
{
5-
public function testOne()
5+
public function testPlay()
66
{
77
$this->assertEmbed(
8-
'http://open.spotify.com/track/7nDQMtLxu94xtlTR8bEqjU',
8+
'https://play.spotify.com/album/7s66wU1XJ2NsUuWM2NKiUV',
99
[
10-
'title' => 'Zhu - Faded',
10+
'title' => 'Various Artists - A Cantar con Xabarin (Vol. I & II)',
1111
'type' => 'rich',
12-
'code' => '<iframe src="https://embed.spotify.com/?uri=spotify:track:7nDQMtLxu94xtlTR8bEqjU" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>',
12+
'code' => '<iframe src="https://embed.spotify.com/?uri=spotify:album:7s66wU1XJ2NsUuWM2NKiUV" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>',
13+
'providerName' => 'Spotify',
14+
'providerUrl' => 'https://www.spotify.com',
15+
]
16+
);
17+
}
18+
19+
public function testOpen()
20+
{
21+
$this->assertEmbed(
22+
'https://open.spotify.com/album/7s66wU1XJ2NsUuWM2NKiUV',
23+
[
24+
'title' => 'Various Artists - A Cantar con Xabarin (Vol. I & II)',
25+
'type' => 'rich',
26+
'code' => '<iframe src="https://embed.spotify.com/?uri=spotify:album:7s66wU1XJ2NsUuWM2NKiUV" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>',
1327
'providerName' => 'Spotify',
1428
'providerUrl' => 'https://www.spotify.com',
1529
]

0 commit comments

Comments
 (0)