[FIX] router: better support for hash mode

This commit is contained in:
Géry Debongnie
2019-08-31 09:46:20 +02:00
parent 6ff4dd74bf
commit 55be6437f1
2 changed files with 80 additions and 25 deletions
+5 -1
View File
@@ -164,7 +164,8 @@ export class Router {
parts[i] = <string>params[key];
}
}
return parts.join("/");
const prefix = this.mode === "hash" ? "#" : "";
return prefix + parts.join("/");
}
private currentPath(): string {
@@ -223,6 +224,9 @@ export class Router {
if (route.path === "*") {
return {};
}
if (path.startsWith("#")) {
path = path.slice(1);
}
const descrParts = route.path.split("/");
const targetParts = path.split("/");
const l = descrParts.length;