|
|
@ -15,17 +15,49 @@ class TestURL extends \JKingWeb\Arsse\Test\AbstractTest { |
|
|
|
} |
|
|
|
|
|
|
|
/** @dataProvider provideNormalizations */ |
|
|
|
public function testNormalizeAUrl(string $in, string $exp) { |
|
|
|
$this->assertSame($exp, URL::normalize($in)); |
|
|
|
public function testNormalizeAUrl(string $url, string $exp, string $user = null, string $pass = null) { |
|
|
|
$this->assertSame($exp, URL::normalize($url, $user, $pass)); |
|
|
|
} |
|
|
|
|
|
|
|
public function provideNormalizations() { |
|
|
|
return [ |
|
|
|
["/", "/"], |
|
|
|
["//example.com/", "//example.com/"], |
|
|
|
["http://example.com/", "http://example.com/"], |
|
|
|
["http://[::1]/", "http://[::1]/"], |
|
|
|
["http://example.com/", "http://example.com/"], |
|
|
|
["HTTP://example.com/", "http://example.com/"], |
|
|
|
["http://example.com", "http://example.com/"], |
|
|
|
["http://example.com:/", "http://example.com/"], |
|
|
|
["HTTP://example.com:80/", "http://example.com:80/"], |
|
|
|
["HTTP://example.com:80", "http://example.com:80/"], |
|
|
|
["http://example.com/?", "http://example.com/"], |
|
|
|
["http://example.com?", "http://example.com/"], |
|
|
|
["http://example.com/#fragment", "http://example.com/"], |
|
|
|
["http://example.com#fragment", "http://example.com/"], |
|
|
|
["http://example.com?#", "http://example.com/"], |
|
|
|
["http://example.com/?key=value", "http://example.com/?key=value"], |
|
|
|
["http://example.com/", "http://user:pass@example.com/", "user", "pass"], |
|
|
|
["http://example.com/", "http://user@example.com/", "user"], |
|
|
|
["http://user:pass@example.com/", "http://user:pass@example.com/"], |
|
|
|
["http://user@example.com/", "http://user@example.com/"], |
|
|
|
["http://user:pass@example.com/", "http://u:p@example.com/", "u", "p"], |
|
|
|
["http://user:pass@example.com/", "http://u@example.com/", "u"], |
|
|
|
["http://user:pass@example.com/", "http://user:pass@example.com/", "", "p"], |
|
|
|
["http://example.com/", "http://example.com/", "", "p"], |
|
|
|
["http://example.com/path", "http://example.com/path"], |
|
|
|
["http://example.com/path/", "http://example.com/path/"], |
|
|
|
["http://example.com/path/.", "http://example.com/path"], |
|
|
|
["http://example.com/path/./", "http://example.com/path/"], |
|
|
|
["http://example.com/path/..", "http://example.com/"], |
|
|
|
["http://example.com/path/../", "http://example.com/"], |
|
|
|
["http://example.com/a/b/..", "http://example.com/a"], |
|
|
|
["http://example.com/a/b/../", "http://example.com/a/"], |
|
|
|
["http://example.com/../", "http://example.com/"], |
|
|
|
["http://example.com////", "http://example.com/"], |
|
|
|
["http://example.com/a/./b/", "http://example.com/a/b/"], |
|
|
|
["http://example.com/a/../b/", "http://example.com/b/"], |
|
|
|
["http://example.com/.a/", "http://example.com/.a/"], |
|
|
|
["http://example.com/..a/", "http://example.com/..a/"], |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|