Skip to content

Commit

Permalink
Allow underscores in web url
Browse files Browse the repository at this point in the history
  • Loading branch information
gordalina committed Jan 25, 2022
1 parent 46108f3 commit c9306af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Adapter/Http/SymfonyHttpClient.php
Expand Up @@ -29,7 +29,7 @@ public function fetch($filename)
try {
$url = "{$this->baseUrl}/{$filename}";

if (!filter_var($url, FILTER_VALIDATE_URL)) {
if (!parse_url($url, PHP_URL_HOST)) {
throw new \RuntimeException(
sprintf(
"The given url is not valid: %s, did you forget to specify the --web-url option?",
Expand Down
8 changes: 7 additions & 1 deletion tests/Adapter/Http/FileGetContentsTest.php
Expand Up @@ -13,7 +13,7 @@ class FileGetContentsTest extends \PHPUnit\Framework\TestCase

public static function setUpBeforeClass(): void
{
self::$process = new Process(['php', '-S', 'localhost:9999', '-t', '.']);
self::$process = new Process(['php', '-S', '127.0.0.1:9999', '-t', '.']);
self::$process->start();

usleep(100000); //wait for server to get going
Expand All @@ -30,6 +30,12 @@ public function testFetch()
$this->assertStringStartsWith('# CacheTool', $client->fetch('README.md'));
}

public function testFetchUnderscores()
{
$client = new SymfonyHttpClient('http://_.127.0.0.1.sslip.io:9999');
$this->assertStringStartsWith('# CacheTool', $client->fetch('README.md'));
}

public function testFetchFailed()
{
$client = new FileGetContents('http://localhost:9999');
Expand Down
8 changes: 7 additions & 1 deletion tests/Adapter/Http/SymfonyHttpClientTest.php
Expand Up @@ -13,7 +13,7 @@ class SymfonyHttpClientTest extends \PHPUnit\Framework\TestCase

public static function setUpBeforeClass(): void
{
self::$process = new Process(['php', '-S', 'localhost:9999', '-t', '.']);
self::$process = new Process(['php', '-S', '127.0.0.1:9999', '-t', '.']);
self::$process->start();

usleep(100000); //wait for server to get going
Expand All @@ -30,6 +30,12 @@ public function testFetch()
$this->assertStringStartsWith('# CacheTool', $client->fetch('README.md'));
}

public function testFetchUnderscores()
{
$client = new SymfonyHttpClient('http://_.127.0.0.1.sslip.io:9999');
$this->assertStringStartsWith('# CacheTool', $client->fetch('README.md'));
}

public function testFetchFailed()
{
$client = new SymfonyHttpClient('http://localhost:9999');
Expand Down

0 comments on commit c9306af

Please sign in to comment.