summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorNayeem Rahman <muhammed.9939@gmail.com>2019-09-11 21:20:54 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-09-11 16:20:54 -0400
commitad11f2ad6aae758e67734d60f068285fb5e10655 (patch)
treef78d2fbb82ac5e84361eb916f585984071131e0d /js
parentf38bd45bf98cf5a642e2b89b4b7369548025995d (diff)
Default base URL path to '/' (#2921)
Diffstat (limited to 'js')
-rw-r--r--js/url.ts2
-rw-r--r--js/url_test.ts4
2 files changed, 5 insertions, 1 deletions
diff --git a/js/url.ts b/js/url.ts
index a2562b9a3..f22198da4 100644
--- a/js/url.ts
+++ b/js/url.ts
@@ -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&param2");
url.searchParams.delete("param1");