Skip to content

Commit 885cde6

Browse files
committed
microoptimization
1 parent e168d11 commit 885cde6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/HttpsTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private function isSkippedHttpStrictTransportSecurity(string $uriScheme, $match,
5858
private function withWwwPrefixWhenRequired(string $httpsRequestUri) : string
5959
{
6060
$addWwwPrefix = $this->config['add_www_prefix'] ?? false;
61-
$alreadyHasWwwPrefix = \substr($httpsRequestUri, 8, 4) === 'www.';
61+
$alreadyHasWwwPrefix = \strpos($httpsRequestUri, 'www.', 8) === 8;
6262

6363
if (! $addWwwPrefix || $alreadyHasWwwPrefix) {
6464
return $httpsRequestUri;
@@ -79,7 +79,7 @@ private function withoutWwwPrefixWhenNotRequired(string $httpsRequestUri) : stri
7979
}
8080

8181
$removeWwwPrefix = $this->config['remove_www_prefix'] ?? false;
82-
$alreadyHasWwwPrefix = \substr($httpsRequestUri, 8, 4) === 'www.';
82+
$alreadyHasWwwPrefix = \strpos($httpsRequestUri, 'www.', 8) === 8;
8383

8484
if (! $removeWwwPrefix || ! $alreadyHasWwwPrefix) {
8585
return $httpsRequestUri;

0 commit comments

Comments
 (0)