-
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure it has not already been reported
Version (i.e. v2.x.x)
1.0.1-alpha.212
Node.js version (i.e. 18.x, or N/A)
No response
Operating system
None
Operating system version (i.e. 20.04, 11.3, 10, or N/A)
No response
Description
It appears sameDocument is true for the entire origin, it should only be true for same origin + pathname + search, excluding the fragment
Steps to Reproduce
const cases = [
{
source: "/",
target: `/`,
sameDocument: true
},
{
source: "/#a",
target: `/#b`,
sameDocument: true
},
{
source: "/?a=1",
target: `/?a=1`,
sameDocument: true
},
{
source: "/?a=1#a",
target: `/?a=1#b`,
sameDocument: true
},
{
source: "/?a=1",
target: `/?b=1`,
sameDocument: false
},
{
source: "/",
target: `https://${Math.random()}.com/example`,
sameDocument: false
}
]
const navigation = new Navigation();
await navigation.navigate("/").finished;
for (const { source, target, sameDocument} of cases) {
const { origin } = new URL(navigation.currentEntry.url);
await navigation.navigate(source).finished;
const promise = new Promise<NavigateEvent>(
resolve => navigation.addEventListener(
"navigate",
(event) => {
event.intercept({
async handler() {
resolve(event);
}
})
},
{ once: true }
)
);
await navigation.navigate(target).finished;
const event = await promise;
ok(new URL(event.destination.url).toString() === new URL(target, origin).toString(), `Expected url to be ${target}, got ${event.destination.url}`);
ok(event.destination.sameDocument === sameDocument, `Expected same document to be ${sameDocument} going from ${source} to ${target}`);
}
Expected same document to be false going from /?a=1 to /?b=1
Expected Behavior
A passed test
Metadata
Metadata
Assignees
Labels
No labels