mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
acac9d1741
Before this commit, params in paths had to be be between slashes and
comprise the entirety of the contents between those slashes (eg:
`/books/{{id}}/{{name}}`)
This is unnecessarily restrictive. This commit removes this restriction,
which allows for paths such as:
- `/books/{{id}}-{{name}}`
- `#books&id={{id}}&name={{name}}`
among others
closes #858
27 lines
742 B
TypeScript
27 lines
742 B
TypeScript
import { Router, Route, RouterEnv } from "../../src/router/router";
|
|
import { makeTestEnv } from "../helpers";
|
|
import { QWeb } from "../../src/qweb/index";
|
|
|
|
export class TestRouter extends Router {
|
|
destroy() {
|
|
window.removeEventListener("popstate", (this as any)._listener);
|
|
|
|
// remove component defined inroutes
|
|
for (let key in QWeb.components) {
|
|
if (key.startsWith("__component__")) {
|
|
delete QWeb.components[key];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export function getRouteParams(route: Partial<Route>, path: string) {
|
|
const env = <RouterEnv>makeTestEnv();
|
|
const router = new TestRouter(env, [route]);
|
|
const {
|
|
routeIds: [routeId],
|
|
routes,
|
|
} = router;
|
|
return router["getRouteParams"](routes[routeId], path);
|
|
}
|