diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2019-09-11 21:20:54 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-09-11 16:20:54 -0400 |
commit | ad11f2ad6aae758e67734d60f068285fb5e10655 (patch) | |
tree | f78d2fbb82ac5e84361eb916f585984071131e0d /js | |
parent | f38bd45bf98cf5a642e2b89b4b7369548025995d (diff) |
Default base URL path to '/' (#2921)
Diffstat (limited to 'js')
-rw-r--r-- | js/url.ts | 2 | ||||
-rw-r--r-- | js/url_test.ts | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -333,7 +333,7 @@ export class URL { password: baseParts.password, hostname: baseParts.hostname, port: baseParts.port, - path: resolvePathFromBase(urlParts.path, baseParts.path), + path: resolvePathFromBase(urlParts.path, baseParts.path || "/"), query: urlParts.query, hash: urlParts.hash }; diff --git a/js/url_test.ts b/js/url_test.ts index c42025929..07a8028ce 100644 --- a/js/url_test.ts +++ b/js/url_test.ts @@ -152,6 +152,10 @@ test(function urlRelativeWithBase(): void { assertEquals(new URL("../b", "file:///a/a/a").href, "file:///a/b"); }); +test(function emptyBasePath(): void { + assertEquals(new URL("", "http://example.com").href, "http://example.com/"); +}); + test(function deletingAllParamsRemovesQuestionMarkFromURL(): void { const url = new URL("http://example.com/?param1¶m2"); url.searchParams.delete("param1"); |