Skip to content

Commit d6ef402

Browse files
committed
Url: host can end with dot [Closes #198]
1 parent 792f6b4 commit d6ef402

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Http/Url.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,11 @@ public function isEqual($url): bool
351351
ksort($query);
352352
$query2 = $this->query;
353353
ksort($query2);
354+
$host = rtrim($url->host, '.');
355+
$host2 = rtrim($this->host, '.');
354356
return $url->scheme === $this->scheme
355-
&& (!strcasecmp($url->host, $this->host)
356-
|| self::idnHostToUnicode($url->host) === self::idnHostToUnicode($this->host))
357+
&& (!strcasecmp($host, $host2)
358+
|| self::idnHostToUnicode($host) === self::idnHostToUnicode($host2))
357359
&& $url->getPort() === $this->getPort()
358360
&& $url->user === $this->user
359361
&& $url->password === $this->password
@@ -375,6 +377,7 @@ public function canonicalize()
375377
function (array $m): string { return rawurlencode($m[0]); },
376378
self::unescape($this->path, '%/')
377379
);
380+
$this->host = rtrim($this->host, '.');
378381
$this->host = self::idnHostToUnicode(strtolower($this->host));
379382
return $this;
380383
}

tests/Http/Url.isEqual().phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ Assert::true($url->isEqual('http://example.com'));
5656

5757
$url = new Url('https://xn--tst-qla.de/');
5858
Assert::true($url->isEqual('https://täst.de/'));
59+
60+
61+
// dots at end
62+
$url = new Url('https://google.com./abcd');
63+
Assert::true($url->isEqual('https://google.com/abcd'));
64+
$url = new Url('https://xn--tst-qla.de./');
65+
Assert::true($url->isEqual('https://täst.de/'));

0 commit comments

Comments
 (0)