Skip to content

Commit 70017ea

Browse files
committed
added support for google drive
1 parent 641f55b commit 70017ea

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Adapters/Google.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static function check(Request $request)
1818
return $request->match([
1919
'https://maps.google.*',
2020
'https://www.google.*/maps*',
21+
'https://drive.google.com/file/*/view',
2122
]);
2223
}
2324

@@ -26,9 +27,14 @@ public static function check(Request $request)
2627
*/
2728
public function getCode()
2829
{
29-
$url = (new Url($this->request->getUrl()))
30-
->withQueryParameter('output', 'embed')
31-
->withQueryParameter('s', '');
30+
$url = new Url($this->request->getUrl());
31+
32+
if ($this->request->getHost() === 'drive.google.com') {
33+
$url = $url->withDirectoryPosition(3, 'preview');
34+
} else {
35+
$url->withQueryParameter('output', 'embed')
36+
->withQueryParameter('s', '');
37+
}
3238

3339
return Utils::iframe($url->getUrl());
3440
}

tests/GoogleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,14 @@ public function testMap()
99
$this->assertEquals($info->type, 'rich');
1010
$this->assertEquals($info->providerName, 'Google Maps');
1111
}
12+
13+
public function testDrive()
14+
{
15+
$info = Embed\Embed::create('https://drive.google.com/file/d/0B2rwN8wAbVSWbmFJdUdnV2VSTTg/view');
16+
17+
$this->assertEquals($info->title, 'Entrevista_Rianxo_RadioFusion_150724.mp3');
18+
$this->assertEquals($info->type, 'rich');
19+
$this->assertEquals($info->code, '<iframe src="https://drive.google.com/file/d/0B2rwN8wAbVSWbmFJdUdnV2VSTTg/preview?usp=embed_facebook&amp;pli=1" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:600px;height:400px;"></iframe>');
20+
$this->assertEquals($info->providerName, 'Google Docs');
21+
}
1222
}

0 commit comments

Comments
 (0)