Skip to content

Commit 1640d64

Browse files
committed
Fixed redirection urls
1 parent e20b821 commit 1640d64

10 files changed

+736
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [4.2.1] - 2020-05-25
9+
### Fixed
10+
- Redirect urls like `t.co`.
11+
812
## [4.2.0] - 2020-05-23
913
### Added
1014
- Added the `ignored_errors` settings to ignore some curls errors instead throw an exception [#355]
@@ -56,6 +60,7 @@ Full library refactoring.
5660
[#355]: https://github.com/oscarotero/Embed/issues/355
5761
[#356]: https://github.com/oscarotero/Embed/issues/356
5862

63+
[4.2.1]: https://github.com/oscarotero/Embed/compare/v4.2.0...v4.2.1
5964
[4.2.0]: https://github.com/oscarotero/Embed/compare/v4.1.1...v4.2.0
6065
[4.1.1]: https://github.com/oscarotero/Embed/compare/v4.1.0...v4.1.1
6166
[4.1.0]: https://github.com/oscarotero/Embed/compare/v4.0.0...v4.1.0

src/Detectors/Redirect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Redirect extends Detector
1010
public function detect(): ?UriInterface
1111
{
1212
$document = $this->extractor->getDocument();
13-
$value = $document->select('.//meta', ['http-equiv' => 'refresh'])->str();
13+
$value = $document->select('.//meta', ['http-equiv' => 'refresh'])->str('content');
1414

1515
return $value ? $this->extract($value) : null;
1616
}

tests/PagesTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public function testTwitch()
168168
public function testTwitter()
169169
{
170170
$this->assertEmbed('https://twitter.com/pepephone/status/436461658601713664');
171+
$this->assertEmbed('https://t.co/4DK3Jc2BTt');
171172
}
172173

173174
public function testTikTok()

tests/cache/buff.ly.2usohds.php

Lines changed: 258 additions & 0 deletions
Large diffs are not rendered by default.

tests/cache/t.co.4dk3jc2btt.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
return [
5+
'headers' => [
6+
'cache-control' => [
7+
'private,max-age=300'
8+
],
9+
'content-encoding' => [
10+
'gzip'
11+
],
12+
'content-length' => [
13+
'177'
14+
],
15+
'content-type' => [
16+
'text/html; charset=utf-8'
17+
],
18+
'date' => [
19+
'Mon, 25 May 2020 12:14:51 GMT'
20+
],
21+
'expires' => [
22+
'Mon, 25 May 2020 12:19:51 GMT'
23+
],
24+
'server' => [
25+
'tsa_f'
26+
],
27+
'set-cookie' => [
28+
'muc=309dc6f1-7be6-4358-9a6b-8160b5741e97; Max-Age=63072000; Expires=Wed, 25 May 2022 12:14:51 GMT; Domain=t.co; Secure; SameSite=None'
29+
],
30+
'strict-transport-security' => [
31+
'max-age=0'
32+
],
33+
'vary' => [
34+
'Origin'
35+
],
36+
'x-connection-hash' => [
37+
'3d9a006e278127b0557f8feef2737c10'
38+
],
39+
'x-response-time' => [
40+
'122'
41+
],
42+
'x-xss-protection' => [
43+
'0'
44+
],
45+
'Content-Location' => [
46+
'https://t.co/4DK3Jc2BTt'
47+
],
48+
'X-Request-Time' => [
49+
'0.340 ms'
50+
]
51+
],
52+
'statusCode' => 200,
53+
'reasonPhrase' => 'OK',
54+
'body' => '<head><noscript><META http-equiv="refresh" content="0;URL=https://buff.ly/2uSOHDs"></noscript><title>https://buff.ly/2uSOHDs</title></head><script>window.opener = null; location.replace("https:\\/\\/buff.ly\\/2uSOHDs")</script>'
55+
];

tests/cache/www.facebook.com.acolono-videos-10154107990797381.49644076c1c38d3ef6fa11122ea89e53.php

Lines changed: 86 additions & 0 deletions
Large diffs are not rendered by default.

tests/cache/www.facebook.com.permalink.php.cfa702e11f4675f62719bd04210782dc.php

Lines changed: 95 additions & 0 deletions
Large diffs are not rendered by default.

tests/fixtures/buff.ly.2usohds.php

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
return [
5+
'authorName' => '@graffica_info',
6+
'authorUrl' => 'https://twitter.com/graffica_info',
7+
'cms' => null,
8+
'code' => null,
9+
'description' => 'El lenguaje, sea cual sea el idioma, siempre esconde entre los orígenes de sus palabras muchas curiosidades. Este es el caso del origen del ampersand.',
10+
'favicon' => 'https://graffica.info/favicon.ico',
11+
'feeds' => [
12+
'https://graffica.info/feed/'
13+
],
14+
'icon' => null,
15+
'image' => 'https://graffica.info/wp-content/uploads/2020/02/el-origen-de-la-Ampersand-destacado.jpg',
16+
'keywords' => [],
17+
'language' => 'es',
18+
'languages' => [],
19+
'license' => null,
20+
'providerName' => 'Gràffica',
21+
'providerUrl' => 'https://graffica.info',
22+
'publishedTime' => '2020-02-20 09:30:00',
23+
'redirect' => null,
24+
'title' => 'El origen del ampersand que desconocen muchos diseñadores',
25+
'url' => 'https://graffica.info/sabes-cual-es-el-origen-del-ampersand/',
26+
'linkedData' => [
27+
'@context' => 'https://schema.org',
28+
'@graph' => [
29+
[
30+
'@type' => 'WebSite',
31+
'@id' => 'https://graffica.info/#website',
32+
'url' => 'https://graffica.info/',
33+
'name' => 'Gràffica',
34+
'description' => 'Revista de noticias del mundo del diseño, en especial del diseño gráfico, la creatividad y la cultura visual. Tipografía, ilustración, branding y mucho más.',
35+
'potentialAction' => [
36+
[
37+
'@type' => 'SearchAction',
38+
'target' => 'https://graffica.info/?s={search_term_string}',
39+
'query-input' => 'required name=search_term_string'
40+
]
41+
],
42+
'inLanguage' => 'es'
43+
],
44+
[
45+
'@type' => 'ImageObject',
46+
'@id' => 'https://graffica.info/sabes-cual-es-el-origen-del-ampersand/#primaryimage',
47+
'inLanguage' => 'es',
48+
'url' => 'https://graffica.info/wp-content/uploads/2020/02/el-origen-de-la-Ampersand-destacado.jpg',
49+
'width' => 1000,
50+
'height' => 659
51+
],
52+
[
53+
'@type' => 'WebPage',
54+
'@id' => 'https://graffica.info/sabes-cual-es-el-origen-del-ampersand/#webpage',
55+
'url' => 'https://graffica.info/sabes-cual-es-el-origen-del-ampersand/',
56+
'name' => 'El origen del ampersand que desconocen muchos diseñadores',
57+
'isPartOf' => [
58+
'@id' => 'https://graffica.info/#website'
59+
],
60+
'primaryImageOfPage' => [
61+
'@id' => 'https://graffica.info/sabes-cual-es-el-origen-del-ampersand/#primaryimage'
62+
],
63+
'datePublished' => '2020-02-20T09:30:00+00:00',
64+
'dateModified' => '2020-02-20T09:17:48+00:00',
65+
'author' => [
66+
'@id' => 'https://graffica.info/#/schema/person/e061170e01040cb6444c3edea24a464b'
67+
],
68+
'description' => 'El lenguaje, sea cual sea el idioma, siempre esconde entre los orígenes de sus palabras muchas curiosidades. Este es el caso del origen del ampersand.',
69+
'inLanguage' => 'es',
70+
'potentialAction' => [
71+
[
72+
'@type' => 'ReadAction',
73+
'target' => [
74+
'https://graffica.info/sabes-cual-es-el-origen-del-ampersand/'
75+
]
76+
]
77+
]
78+
],
79+
[
80+
'@type' => [
81+
'Person'
82+
],
83+
'@id' => 'https://graffica.info/#/schema/person/e061170e01040cb6444c3edea24a464b',
84+
'name' => 'Gràffica',
85+
'image' => [
86+
'@type' => 'ImageObject',
87+
'@id' => 'https://graffica.info/#personlogo',
88+
'inLanguage' => 'es',
89+
'url' => 'https://secure.gravatar.com/avatar/3149311a3c04959ac810d7ff614188f1?s=96&d=mm&r=g',
90+
'caption' => 'Gràffica'
91+
]
92+
]
93+
]
94+
],
95+
'oEmbed' => []
96+
];
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
return [
5+
'authorName' => 'Acolono GmbH',
6+
'authorUrl' => 'https://www.facebook.com/acolono/',
7+
'cms' => null,
8+
'code' => [
9+
'html' => '<div id="fb-root"></div> <script async="1" defer="1" crossorigin="anonymous" src="https://connect.facebook.net/es_ES/sdk.js#xfbml=1&amp;version=v7.0"></script><div class="fb-video" data-href="https://www.facebook.com/acolono/videos/10154107990797381/"><blockquote cite="https://www.facebook.com/acolono/videos/10154107990797381/" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/acolono/videos/10154107990797381/"></a><p>Eindrücke vom gestrigen Drupal Austria Meetup bei uns im Büro :) Wir haben die beste Community!</p>Publicada por <a href="https://www.facebook.com/acolono/">Acolono GmbH</a> en Jueves, 12 de mayo de 2016</blockquote></div>',
10+
'width' => 500,
11+
'height' => 901
12+
],
13+
'description' => 'Eindrücke vom gestrigen Drupal Austria Meetup bei uns im Büro :) Wir haben die beste Community!',
14+
'favicon' => 'https://static.xx.fbcdn.net/rsrc.php/yo/r/iRmz9lCMBD2.ico',
15+
'feeds' => [],
16+
'icon' => null,
17+
'image' => 'https://scontent.fmad7-1.fna.fbcdn.net/v/t15.5256-10/p200x200/12672727_10154107996122381_1769309167_n.jpg?_nc_cat=110&_nc_sid=ad6a45&_nc_ohc=H5axAn5YdXsAX_e6Lzx&_nc_ht=scontent.fmad7-1.fna&_nc_tp=6&oh=2c06ee1e270f11ec4df87d1a55020804&oe=5EF1D1EE',
18+
'keywords' => [],
19+
'language' => 'es',
20+
'languages' => [],
21+
'license' => null,
22+
'providerName' => 'Facebook',
23+
'providerUrl' => 'https://www.facebook.com/',
24+
'publishedTime' => null,
25+
'redirect' => null,
26+
'title' => 'Acolono GmbH - Eindrücke vom gestrigen Drupal Austria...',
27+
'url' => 'https://www.facebook.com/acolono/videos/10154107990797381/',
28+
'linkedData' => [
29+
'@context' => 'https://schema.org',
30+
'@type' => 'VideoObject',
31+
'name' => 'Acolono GmbH - Eindrücke vom gestrigen Drupal Austria...',
32+
'description' => 'Eindrücke vom gestrigen Drupal Austria Meetup bei uns im Büro :) Wir haben die beste Community!',
33+
'thumbnailUrl' => 'https://scontent.fmad7-1.fna.fbcdn.net/v/t15.5256-10/12672727_10154107996122381_1769309167_n.jpg?_nc_cat=110&_nc_sid=08861d&_nc_ohc=H5axAn5YdXsAX_e6Lzx&_nc_ht=scontent.fmad7-1.fna&oh=408eec961f6799604dbf1faf96633eca&oe=5EF1FFC0',
34+
'duration' => 'T1M1S',
35+
'uploadDate' => '2016-05-12T06:52:59-07:00',
36+
'contentUrl' => 'https://video.fmad7-1.fna.fbcdn.net/v/t42.1790-2/13223999_1021353087901725_2023377136_n.mp4?_nc_cat=109&_nc_sid=985c63&efg=eyJybHIiOjMwMCwicmxhIjo1MTIsInZlbmNvZGVfdGFnIjoic3ZlX3NkIn0%3D&_nc_ohc=ieZd8VLy45AAX9__EdF&rl=300&vabr=152&_nc_ht=video.fmad7-1.fna&oh=3a708437f011a6250a4113c8671e1079&oe=5ECBD9B6',
37+
'interactionCount' => 112,
38+
'publication' => [
39+
[
40+
'@type' => 'BroadcastEvent',
41+
'isLiveBroadcast' => false
42+
]
43+
],
44+
'@id' => 'https://video.fmad7-1.fna.fbcdn.net/v/t42.1790-2/13223999_1021353087901725_2023377136_n.mp4?_nc_cat=109&_nc_sid=985c63&efg=eyJybHIiOjMwMCwicmxhIjo1MTIsInZlbmNvZGVfdGFnIjoic3ZlX3NkIn0%3D&_nc_ohc=ieZd8VLy45AAX9__EdF&rl=300&vabr=152&_nc_ht=video.fmad7-1.fna&oh=3a708437f011a6250a4113c8671e1079&oe=5ECBD9B6',
45+
'url' => 'https://video.fmad7-1.fna.fbcdn.net/v/t42.1790-2/13223999_1021353087901725_2023377136_n.mp4?_nc_cat=109&_nc_sid=985c63&efg=eyJybHIiOjMwMCwicmxhIjo1MTIsInZlbmNvZGVfdGFnIjoic3ZlX3NkIn0%3D&_nc_ohc=ieZd8VLy45AAX9__EdF&rl=300&vabr=152&_nc_ht=video.fmad7-1.fna&oh=3a708437f011a6250a4113c8671e1079&oe=5ECBD9B6',
46+
'datePublished' => '2016-05-12T06:52:59-07:00',
47+
'width' => 320,
48+
'height' => 576,
49+
'thumbnail' => [
50+
'@type' => 'ImageObject',
51+
'contentUrl' => 'https://scontent.fmad7-1.fna.fbcdn.net/v/t15.5256-10/12672727_10154107996122381_1769309167_n.jpg?_nc_cat=110&_nc_sid=08861d&_nc_ohc=H5axAn5YdXsAX_e6Lzx&_nc_ht=scontent.fmad7-1.fna&oh=408eec961f6799604dbf1faf96633eca&oe=5EF1FFC0',
52+
'width' => 320,
53+
'height' => 576
54+
],
55+
'headline' => 'Acolono GmbH - Eindrücke vom gestrigen Drupal Austria...',
56+
'isFamilyFriendly' => true,
57+
'keywords' => 'Acolono GmbH',
58+
'commentCount' => 0,
59+
'inLanguage' => 'de',
60+
'contentSize' => '5261.361kB',
61+
'videoQuality' => '270p',
62+
'author' => [
63+
'@type' => 'Organization',
64+
'name' => 'Acolono GmbH',
65+
'url' => 'https://www.facebook.com/acolono/'
66+
],
67+
'publisher' => [
68+
'@type' => 'Organization',
69+
'logo' => [
70+
'@type' => 'ImageObject',
71+
'url' => 'https://scontent.fmad7-1.fna.fbcdn.net/v/t1.0-1/p200x200/10440698_10152746215257381_1707589563651819460_n.png?_nc_cat=106&_nc_sid=dbb9e7&_nc_ohc=iki5GvdExDAAX9gpcHG&_nc_ht=scontent.fmad7-1.fna&oh=11cd9277a3a18cb0ec0bcc6987664a9c&oe=5EF20E9A'
72+
],
73+
'name' => 'Acolono GmbH',
74+
'url' => 'https://www.facebook.com/acolono/'
75+
],
76+
'about' => 'Eindrücke vom gestrigen Drupal Austria Meetup bei uns im Büro :) Wir haben die beste Community!',
77+
'transcript' => null
78+
],
79+
'oEmbed' => [
80+
'author_name' => 'Acolono GmbH',
81+
'author_url' => 'https://www.facebook.com/acolono/',
82+
'provider_url' => 'https://www.facebook.com',
83+
'provider_name' => 'Facebook',
84+
'success' => true,
85+
'height' => 901,
86+
'html' => '<div id="fb-root"></div>
87+
<script async="1" defer="1" crossorigin="anonymous" src="https://connect.facebook.net/es_ES/sdk.js#xfbml=1&amp;version=v7.0"></script><div class="fb-video" data-href="https://www.facebook.com/acolono/videos/10154107990797381/"><blockquote cite="https://www.facebook.com/acolono/videos/10154107990797381/" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/acolono/videos/10154107990797381/"></a><p>Eindrücke vom gestrigen Drupal Austria Meetup bei uns im Büro :) Wir haben die beste Community!</p>Publicada por <a href="https://www.facebook.com/acolono/">Acolono GmbH</a> en Jueves, 12 de mayo de 2016</blockquote></div>',
88+
'type' => 'video',
89+
'version' => '1.0',
90+
'url' => 'https://www.facebook.com/acolono/videos/10154107990797381/',
91+
'width' => 500
92+
]
93+
];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
return [
5+
'authorName' => 'DAG, Asociación Galega de Deseño',
6+
'authorUrl' => 'https://www.facebook.com/asociaciondag/',
7+
'cms' => null,
8+
'code' => [
9+
'html' => '<div id="fb-root"></div> <script async="1" defer="1" crossorigin="anonymous" src="https://connect.facebook.net/es_ES/sdk.js#xfbml=1&amp;version=v7.0"></script><div class="fb-post" data-href="https://www.facebook.com/asociaciondag/posts/827163017327807" data-width="552"><blockquote cite="https://www.facebook.com/asociaciondag/posts/827163017327807" class="fb-xfbml-parse-ignore"><p>Aquí vos deixamos unhas imaxes da nosa visita do pasado sábado á Guarda. Moi agradecidos á Asociación Naturalista do Baixo Miño www.anabam.org e a Malde Arqueoloxía</p>Publicada por <a href="https://www.facebook.com/asociaciondag/">DAG, Asociación Galega de Deseño</a> en&nbsp;<a href="https://www.facebook.com/asociaciondag/posts/827163017327807">Martes, 21 de octubre de 2014</a></blockquote></div>',
10+
'width' => 552,
11+
'height' => null
12+
],
13+
'description' => 'Aquí vos deixamos unhas imaxes da nosa visita do pasado sábado á Guarda. Moi agradecidos á Asociación Naturalista do Baixo Miño www.anabam.org e a Malde Arqueoloxía',
14+
'favicon' => 'https://static.xx.fbcdn.net/rsrc.php/yo/r/iRmz9lCMBD2.ico',
15+
'feeds' => [],
16+
'icon' => null,
17+
'image' => 'https://scontent.fmad7-1.fna.fbcdn.net/v/t31.0-8/10704334_827161517327957_5105556928960502376_o.jpg?_nc_cat=111&_nc_sid=8024bb&_nc_ohc=1Tupk385RV8AX9dOJv1&_nc_ht=scontent.fmad7-1.fna&oh=e0e8f81989b1ade9c9e12c3a4a211cba&oe=5EF11523',
18+
'keywords' => [],
19+
'language' => 'es',
20+
'languages' => [
21+
'x-default' => 'https://www.facebook.com/149460691764713/posts/aqu%C3%AD-vos-deixamos-unhas-imaxes-da-nosa-visita-do-pasado-s%C3%A1bado-%C3%A1-guarda-moi-agra/827163017327807/',
22+
'en' => 'https://www.facebook.com/149460691764713/posts/aqu%C3%AD-vos-deixamos-unhas-imaxes-da-nosa-visita-do-pasado-s%C3%A1bado-%C3%A1-guarda-moi-agra/827163017327807/'
23+
],
24+
'license' => null,
25+
'providerName' => 'Facebook',
26+
'providerUrl' => 'https://www.facebook.com/',
27+
'publishedTime' => null,
28+
'redirect' => null,
29+
'title' => 'Aquí vos deixamos unhas imaxes da nosa... - DAG, Asociación Galega de Deseño | Facebook',
30+
'url' => 'https://www.facebook.com/asociaciondag/posts/827163017327807',
31+
'linkedData' => [],
32+
'oEmbed' => [
33+
'author_name' => 'DAG, Asociación Galega de Deseño',
34+
'author_url' => 'https://www.facebook.com/asociaciondag/',
35+
'provider_url' => 'https://www.facebook.com',
36+
'provider_name' => 'Facebook',
37+
'success' => true,
38+
'height' => null,
39+
'html' => '<div id="fb-root"></div>
40+
<script async="1" defer="1" crossorigin="anonymous" src="https://connect.facebook.net/es_ES/sdk.js#xfbml=1&amp;version=v7.0"></script><div class="fb-post" data-href="https://www.facebook.com/asociaciondag/posts/827163017327807" data-width="552"><blockquote cite="https://www.facebook.com/asociaciondag/posts/827163017327807" class="fb-xfbml-parse-ignore"><p>Aquí vos deixamos unhas imaxes da nosa visita do pasado sábado á Guarda. Moi agradecidos á Asociación Naturalista do Baixo Miño www.anabam.org e a Malde Arqueoloxía</p>Publicada por <a href="https://www.facebook.com/asociaciondag/">DAG, Asociación Galega de Deseño</a> en&nbsp;<a href="https://www.facebook.com/asociaciondag/posts/827163017327807">Martes, 21 de octubre de 2014</a></blockquote></div>',
41+
'type' => 'rich',
42+
'version' => '1.0',
43+
'url' => 'https://www.facebook.com/asociaciondag/posts/827163017327807',
44+
'width' => 552
45+
]
46+
];

0 commit comments

Comments
 (0)