mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
committed by
Aaron Bohy
parent
5911c8e3f6
commit
2aa705f5c8
@@ -148,7 +148,7 @@ export class Router {
|
|||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
private setUrlFromPath(path: string) {
|
private setUrlFromPath(path: string) {
|
||||||
const separator = this.mode === "hash" ? "/" : "";
|
const separator = this.mode === "hash" ? location.pathname : "";
|
||||||
const url = location.origin + separator + path;
|
const url = location.origin + separator + path;
|
||||||
if (url !== window.location.href) {
|
if (url !== window.location.href) {
|
||||||
window.history.pushState({}, path, url);
|
window.history.pushState({}, path, url);
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ describe("router miscellaneous", () => {
|
|||||||
expect(window.location.hash).toBe("#/users/5");
|
expect(window.location.hash).toBe("#/users/5");
|
||||||
expect(env.qweb.forceUpdate).toHaveBeenCalledTimes(2);
|
expect(env.qweb.forceUpdate).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("navigate in hash mode preserve location", async () => {
|
||||||
|
router = new TestRouter(env, [{ name: "users", path: "/users/{{id}}" }], {mode: "hash"});
|
||||||
|
window.history.pushState({}, "title", window.location.origin + '/test.html');
|
||||||
|
expect(window.location.href).toBe("http://localhost/test.html");
|
||||||
|
await router.navigate({ to: "users", params: { id: 3 } });
|
||||||
|
expect(window.location.href).toBe("http://localhost/test.html#/users/3");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("routeToPath", () => {
|
describe("routeToPath", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user