From 168bdb76ce1eb55eb92b63c364000c7e89fc2a99 Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Wed, 7 May 2025 16:59:43 +0200 Subject: [PATCH 1/2] Only match exact main and subdomains --- src/ExtractorFactory.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ExtractorFactory.php b/src/ExtractorFactory.php index 55624f6c..8e3e9928 100644 --- a/src/ExtractorFactory.php +++ b/src/ExtractorFactory.php @@ -46,7 +46,14 @@ public function createExtractor(UriInterface $uri, RequestInterface $request, Re $class = $this->default; foreach ($this->adapters as $adapterHost => $adapter) { - if (substr($host, -strlen($adapterHost)) === $adapterHost) { + // Check if $host is the same domain as $adapterHost. + if ($host === $adapterHost) { + $class = $adapter; + break; + } + + // Check if $host is a subdomain of $adapterHost. + if (preg_match('/^([a-z0-9-]+)\.' . preg_quote($adapterHost, '/') . '$/i', $host, $matches)) { $class = $adapter; break; } From 074bb421b977254d88125bb71962074bbe3e6c98 Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Fri, 9 May 2025 16:08:02 +0200 Subject: [PATCH 2/2] Stop using regex --- src/ExtractorFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExtractorFactory.php b/src/ExtractorFactory.php index 8e3e9928..9ba37e0b 100644 --- a/src/ExtractorFactory.php +++ b/src/ExtractorFactory.php @@ -53,7 +53,7 @@ public function createExtractor(UriInterface $uri, RequestInterface $request, Re } // Check if $host is a subdomain of $adapterHost. - if (preg_match('/^([a-z0-9-]+)\.' . preg_quote($adapterHost, '/') . '$/i', $host, $matches)) { + if (substr($host, -strlen($adapterHost) + 1) === ".{$adapterHost}") { $class = $adapter; break; }