Skip to content

Commit e841dc1

Browse files
committed
Get rid of regexp
1 parent ea987ab commit e841dc1

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/Adapters/N500px.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ public static function check(Request $request)
2828
*/
2929
public function getCode()
3030
{
31-
$url=$this->getUrl();
32-
$matches=array();
33-
preg_match('#(https?://500px.com/photo/\d+)#si',$this->getUrl(),$matches);
34-
if (isset($matches[1]) && $matches[1]) {
35-
return Utils::iframe($matches[1].'/embed.html', $this->getWidth(), $this->getHeight());
36-
}
31+
if (is_numeric($this->request->getDirectoryPosition(1))) {
32+
return Utils::iframe($this->request->createUrl()->withDirectoryPosition(2,'embed.html'), $this->width, $this->height);
33+
}
34+
3735
return '';
3836
}
3937

src/Providers/OEmbed/N500px.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ class N500px extends OEmbedImplementation
1414
*/
1515
public static function getEndPoint(Url $url)
1616
{
17-
$matches=array();
18-
preg_match('#(https?://500px.com/photo/\d+/)#si', $url->getUrl(),$matches);
1917

20-
if (isset($matches[1]) && $matches[1]) {
21-
return $matches[1].'/oembed.json';
22-
}
18+
if (is_numeric($this->request->getDirectoryPosition(1))) {
19+
return $this->request->createUrl()->withDirectoryPosition(2,'oembed.json');
20+
}
2321
return '';
2422
}
2523

0 commit comments

Comments
 (0)