-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix] Throw invalid uris when no scheme is parsed
A valid uri must have a scheme. We do not treat uris without a scheme as valid. Closes #3
- Loading branch information
1 parent
18926f2
commit 1838b32
Showing
2 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
class UriTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getUris | ||
* @dataProvider getValidUris | ||
* | ||
* @throws InvalidUri | ||
*/ | ||
|
@@ -36,7 +36,18 @@ public function testItParsesUris(string $uri, string $parsed): void | |
self::assertSame($parsed, Uri::parse($uri)->toStr()); | ||
} | ||
|
||
public function getUris(): array | ||
/** | ||
* @dataProvider getInvalidUris | ||
* | ||
* @throws InvalidUri | ||
*/ | ||
public function testInvalidUris(string $uri): void | ||
{ | ||
$this->expectException(InvalidUri::class); | ||
Uri::parse($uri); | ||
} | ||
|
||
public function getValidUris(): array | ||
{ | ||
return [ | ||
['https://example.com', 'https://example.com'], | ||
|
@@ -46,4 +57,11 @@ public function getUris(): array | |
['mailto:[email protected]', 'mailto:[email protected]'], | ||
]; | ||
} | ||
|
||
public function getInvalidUris(): array | ||
{ | ||
return [ | ||
['://example.com/protocol-relative-url'], | ||
]; | ||
} | ||
} |