This commit is contained in:
fly_mc 2024-11-27 23:54:13 +08:00
parent 3b37c3e90d
commit 708943f318

View file

@ -60,7 +60,7 @@ export type RouterEvent = {
beforePath: string; beforePath: string;
path: string; path: string;
route: RouteDef | null; route: RouteDef | null;
props: Map<string, string> | null; props: Map<string, string | boolean> | null;
key: string; key: string;
}) => void; }) => void;
same: () => void; same: () => void;
@ -258,7 +258,7 @@ export class Router extends EventEmitter<RouterEvent> implements IRouter {
continue forEachRouteLoop; continue forEachRouteLoop;
} }
} else { } else {
if (parts[0] == null && !p.optional) { if (!parts[0] && !p.optional) {
continue forEachRouteLoop; continue forEachRouteLoop;
} }
if (p.wildcard) { if (p.wildcard) {
@ -269,7 +269,7 @@ export class Router extends EventEmitter<RouterEvent> implements IRouter {
break pathMatchLoop; break pathMatchLoop;
} else { } else {
if (p.startsWith) { if (p.startsWith) {
if (parts[0] == null || !parts[0].startsWith(p.startsWith)) continue forEachRouteLoop; if (!parts[0] || !parts[0].startsWith(p.startsWith)) continue forEachRouteLoop;
props.set(p.name, safeURIDecode(parts[0].substring(p.startsWith.length))); props.set(p.name, safeURIDecode(parts[0].substring(p.startsWith.length)));
parts.shift(); parts.shift();