Skip to content

Commit 231603b

Browse files
committed
Bugfix: Check FB/IG url with pattern before using, otherwise use starting URL
1 parent 179415b commit 231603b

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/Providers/OEmbed/Facebook.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,29 @@ public static function create(Adapter $adapter)
1919
$key = $adapter->getConfig('facebook[key]');
2020

2121
if (!empty($key)) {
22-
return new static($adapter->getResponse(), $key);
22+
$response = $adapter->getResponse();
23+
24+
if ($response->getUrl()->match(static::$pattern)) {
25+
return new static($response, null, $key);
26+
}
27+
28+
if ($response->getStartingUrl()->match(static::$pattern)) {
29+
return new static($response, $response->getStartingUrl(), $key);
30+
}
2331
}
2432
}
2533

2634
/**
2735
* {@inheritdoc}
2836
*/
29-
protected function __construct(Response $response, $key = null)
37+
protected function __construct(Response $response, $url = null, $key = null)
3038
{
3139
$this->response = $response;
3240
$this->key = $key;
41+
42+
if ($url) {
43+
$this->url = $url;
44+
}
3345
}
3446

3547
/**

src/Providers/OEmbed/Instagram.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,29 @@ public static function create(Adapter $adapter)
2424
$key = $adapter->getConfig('facebook[key]');
2525

2626
if (!empty($key)) {
27-
return new static($adapter->getResponse(), $key);
27+
$response = $adapter->getResponse();
28+
29+
if ($response->getUrl()->match(static::$pattern)) {
30+
return new static($response, null, $key);
31+
}
32+
33+
if ($response->getStartingUrl()->match(static::$pattern)) {
34+
return new static($response, $response->getStartingUrl(), $key);
35+
}
2836
}
2937
}
3038

3139
/**
3240
* {@inheritdoc}
3341
*/
34-
protected function __construct(Response $response, $key = null)
42+
protected function __construct(Response $response, $url = null, $key = null)
3543
{
3644
$this->response = $response;
3745
$this->key = $key;
46+
47+
if ($url) {
48+
$this->url = $url;
49+
}
3850
}
3951

4052
/**

0 commit comments

Comments
 (0)