Check for valid scheme in YouTube and Twitter URLs.
This commit is contained in:
parent
ad773e72a7
commit
5fe283a2a7
2 changed files with 4 additions and 1 deletions
|
@ -14,7 +14,7 @@ final class TwitterLookup implements \Uiharu\ILookup {
|
|||
];
|
||||
|
||||
public function match(Url $url): bool {
|
||||
if(!in_array($url->getHost(), self::TWITTER_DOMAINS))
|
||||
if(!$url->isWeb() || !in_array($url->getHost(), self::TWITTER_DOMAINS))
|
||||
return false;
|
||||
|
||||
return preg_match('#^/@?(?:[A-Za-z0-9_]{1,20})/status(?:es)?/([0-9]+)/?$#', $url->getPath())
|
||||
|
|
|
@ -36,6 +36,9 @@ final class YouTubeLookup implements \Uiharu\ILookup {
|
|||
}
|
||||
|
||||
public function match(Url $url): bool {
|
||||
if(!$url->isWeb())
|
||||
return false;
|
||||
|
||||
$urlHost = $url->getHost();
|
||||
if(self::isShortDomain($urlHost))
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue