fix(core): update
This commit is contained in:
@ -13,6 +13,7 @@ export interface IRouteInfo {
|
||||
path: string;
|
||||
index: number;
|
||||
params: { [key: string]: string };
|
||||
queryParams: { [key: string]: string };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,13 +81,19 @@ export class SmartRouter {
|
||||
*/
|
||||
async _handleRouteState() {
|
||||
const currentLocation = window.location.pathname;
|
||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||
|
||||
// lets find all wanted routes.
|
||||
const wantedRoutes = this.routes.filter((routeArg) => {
|
||||
return !!routeArg.matchFunction(currentLocation);
|
||||
});
|
||||
|
||||
for (const wantedRoute of wantedRoutes) {
|
||||
const routeResult = wantedRoute.matchFunction(currentLocation);
|
||||
wantedRoute.handler(routeResult.valueOf() as IRouteInfo); // not waiting here
|
||||
wantedRoute.handler({
|
||||
...(routeResult.valueOf() as Object),
|
||||
queryParams: Object.fromEntries(urlSearchParams.entries()),
|
||||
} as IRouteInfo); // not waiting here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user