diff --git a/src/Url.php b/src/Url.php index b7c347c..94e9f21 100644 --- a/src/Url.php +++ b/src/Url.php @@ -18,7 +18,7 @@ public function __construct(string $url) $url = "https://{$url}"; } - if (function_exists('idn_to_ascii')) { + if (strlen($url) < 61 && function_exists('idn_to_ascii')) { $url = idn_to_ascii($url, false, INTL_IDNA_VARIANT_UTS46); } diff --git a/tests/UrlTest.php b/tests/UrlTest.php index 886b55b..b6a8987 100644 --- a/tests/UrlTest.php +++ b/tests/UrlTest.php @@ -47,4 +47,12 @@ public function it_can_retrieve_the_custom_port_when_defined() $this->assertSame(12345, $url->getPort()); } + + /** @test */ + public function it_can_parse_really_long_paths() + { + $url = new Url('https://random.host/this-is-a-very/and-i-mean-very/long-path/to-work/with/and-somehow/the-idna-functions-in-php/are-limited-to/61-chars/yes?really=true&ohmy'); + + $this->assertSame('random.host', $url->getHostName()); + } }