[VkBridge] Add detectParameters (#3351)

This commit is contained in:
Eugene Molotov 2023-04-18 21:41:11 +05:00 committed by GitHub
parent 0718fdc829
commit 7c4591c550
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,9 +22,18 @@ class VkBridge extends BridgeAbstract
]
]
];
const TEST_DETECT_PARAMETERS = [
'https://vk.com/id1' => ['u' => 'id1'],
'https://vk.com/groupname' => ['u' => 'groupname'],
'https://m.vk.com/groupname' => ['u' => 'groupname'],
'https://vk.com/groupname/anythingelse' => ['u' => 'groupname'],
'https://vk.com/groupname?w=somethingelse' => ['u' => 'groupname'],
'https://vk.com/with_underscore' => ['u' => 'with_underscore'],
];
protected $pageName;
protected $tz = 0;
private $urlRegex = '/vk\.com\/([\w]+)/';
public function getURI()
{
@ -44,6 +53,15 @@ class VkBridge extends BridgeAbstract
return parent::getName();
}
public function detectParameters($url)
{
if (preg_match($this->urlRegex, $url, $matches)) {
return ['u' => $matches[1]];
}
return null;
}
public function collectData()
{
$text_html = $this->getContents();