diff --git a/src/core/url.ts b/src/core/url.ts
index 0e45d8f2b..3364f53ba 100644
--- a/src/core/url.ts
+++ b/src/core/url.ts
@@ -59,9 +59,5 @@ function getLastPathComponent(url: URL) {
}
function getPrefix(url: URL) {
- return addTrailingSlash(url.origin + url.pathname)
-}
-
-function addTrailingSlash(value: string) {
- return value.endsWith("/") ? value : value + "/"
+ return url.origin + url.pathname;
}
diff --git a/src/tests/fixtures/root/index.html b/src/tests/fixtures/root/index.html
new file mode 100644
index 000000000..f1b71ff4a
--- /dev/null
+++ b/src/tests/fixtures/root/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+ Turbo
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tests/fixtures/root/page.html b/src/tests/fixtures/root/page.html
new file mode 100644
index 000000000..1bc7ac184
--- /dev/null
+++ b/src/tests/fixtures/root/page.html
@@ -0,0 +1,18 @@
+
+
+
+
+ Turbo
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tests/functional/root_tests.ts b/src/tests/functional/root_tests.ts
new file mode 100644
index 000000000..5d4bad25f
--- /dev/null
+++ b/src/tests/functional/root_tests.ts
@@ -0,0 +1,27 @@
+import { test } from "@playwright/test"
+import { assert } from "chai"
+import { nextBody, pathname, visitAction } from "../helpers/page"
+
+test("test visiting a location inside the root", async ({ page }) => {
+ page.goto("/src/tests/fixtures/root/index.html")
+ page.click("#link-page-inside")
+ await nextBody(page)
+ assert.equal(pathname(page.url()), "/src/tests/fixtures/root/page.html")
+ assert.notEqual(await visitAction(page), "load")
+})
+
+test("test visiting the root itself", async ({ page }) => {
+ page.goto("/src/tests/fixtures/root/page.html")
+ page.click("#link-root")
+ await nextBody(page)
+ assert.equal(pathname(page.url()), "/src/tests/fixtures/root/")
+ assert.notEqual(await visitAction(page), "load")
+})
+
+test("test visiting a location outside the root", async ({ page }) => {
+ page.goto("/src/tests/fixtures/root/index.html")
+ page.click("#link-page-outside")
+ await nextBody(page)
+ assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html")
+ assert.equal(await visitAction(page), "load")
+})
\ No newline at end of file