mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] router: add support for more arbitrary param placements in paths
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
This commit is contained in:
committed by
Géry Debongnie
parent
968a5460bb
commit
acac9d1741
@@ -1,4 +1,5 @@
|
||||
import { Router } from "../../src/router/router";
|
||||
import { Router, Route, RouterEnv } from "../../src/router/router";
|
||||
import { makeTestEnv } from "../helpers";
|
||||
import { QWeb } from "../../src/qweb/index";
|
||||
|
||||
export class TestRouter extends Router {
|
||||
@@ -13,3 +14,13 @@ export class TestRouter extends Router {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user