Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
verfriemelt-dot-org committed Nov 21, 2024
1 parent 8a7dfc0 commit 663ab87
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions _/HttpClient/Psr/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ private function parse(): void
return $input;
};

$this->scheme = $assertString($results[0]);
$this->userInfo = $assertString($results[1]);
$this->host = $assertString($results[2]);
$this->port = $assertInt($results[3]);
$this->path = $assertString($results[4]);
$this->query = $assertString($results[5]);
$this->fragment = $assertString($results[6]);
$this->scheme = $assertString($results['scheme']);
$this->userInfo = $assertString($results['userInfo']);
$this->host = $assertString($results['host']);
$this->port = $assertInt($results['port']);
$this->path = $assertString($results['path']);
$this->query = $assertString($results['query']);
$this->fragment = $assertString($results['fragment']);

// fix path
$this->path = \str_replace(' ', '%20', $this->path);
Expand Down
10 changes: 9 additions & 1 deletion _/HttpClient/UriParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ public static function parser(): Parser
static::path(),
static::query(),
static::fragment(),
);
)->map(fn (array $result): array => [
'scheme' => $result[0],
'userInfo' => $result[1],
'host' => $result[2],
'port' => $result[3],
'path' => $result[4],
'query' => $result[5],
'fragment' => $result[6],
]);
}

public static function scheme(): Parser
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/HttpClient/UriParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ public function test_regression_with_only_path(): void
{
$result = UriParser::parser()->run(new ParserInput('/foobar'))->getResult();

static::assertIsList($result);
static::assertIsArray($result);
static::assertCount(7, $result);
static::assertSame('', $result[2], 'host part empty');
static::assertSame('/foobar', $result[4], 'uri part populated');
static::assertSame('', $result['host'], 'host part empty');
static::assertSame('/foobar', $result['path'], 'uri part populated');

}
}

0 comments on commit 663ab87

Please sign in to comment.