From 2c2db55298fee0281b6099dd595cbf364c2b0286 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Wed, 24 Jun 2020 21:07:49 -0400
Subject: [PATCH] Add support for mobile profile URL to core twitter probing

---
 src/Network/Probe.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Network/Probe.php b/src/Network/Probe.php
index 879ccf7fe..41682572c 100644
--- a/src/Network/Probe.php
+++ b/src/Network/Probe.php
@@ -692,7 +692,7 @@ class Probe
 		$parts = parse_url($uri);
 
 		if (!empty($parts['scheme']) && !empty($parts['host'])) {
-			if ($parts['host'] == 'twitter.com') {
+			if (in_array($parts['host'], ['twitter.com', 'mobile.twitter.com'])) {
 				return self::twitter($uri);
 			}
 		} elseif (strstr($uri, '@')) {
@@ -706,7 +706,9 @@ class Probe
 				return self::mail($uri, $uid);
 			}
 
-			if (strpos($uri, '@twitter.com')) {
+			if (Strings::endsWith($uri, '@twitter.com')
+				|| Strings::endsWith($uri, '@mobile.twitter.com')
+			) {
 				return self::twitter($uri);
 			}
 		} else {
@@ -1720,9 +1722,9 @@ class Probe
 	 */
 	private static function twitter($uri)
 	{
-		if (preg_match('=(.*)@twitter.com=i', $uri, $matches)) {
+		if (preg_match('=([^@]+)@(?:mobile\.)?twitter\.com$=i', $uri, $matches)) {
 			$nick = $matches[1];
-		} elseif (preg_match('=https?://twitter.com/(.*)=i', $uri, $matches)) {
+		} elseif (preg_match('=^https?://(?:mobile\.)?twitter\.com/(.+)=i', $uri, $matches)) {
 			$nick = $matches[1];
 		} else {
 			return [];