From 7c4591c550e6f4fba6bb4a67be1aa9d1686a9620 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Tue, 18 Apr 2023 21:41:11 +0500 Subject: [PATCH] [VkBridge] Add detectParameters (#3351) --- bridges/VkBridge.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php index f4ba522a..0b00fca7 100644 --- a/bridges/VkBridge.php +++ b/bridges/VkBridge.php @@ -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();