Skip to content

Commit

Permalink
Fixed unmatched route resolved as internal
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleeckx committed Feb 17, 2017
1 parent 3346208 commit 653355b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/WebComponents/App/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,17 @@ namespace Vidyano.WebComponents {
return;

const anchorParent = this.findParent((e: HTMLElement) => e.tagName === "A" && !!(<HTMLAnchorElement>e).href, e.target as HTMLElement) as HTMLAnchorElement;
if (anchorParent && anchorParent.href.startsWith(Vidyano.Path.routes.root) && !anchorParent.hasAttribute("download") && !anchorParent.hasAttribute("external")) {
if (anchorParent.hash && anchorParent.hash.startsWith("#!/"))
this.changePath(anchorParent.hash.substr(2));
else
this.changePath(App.removeRootPath(anchorParent.pathname));

e.stopPropagation();
e.preventDefault();
if (anchorParent && anchorParent.href.startsWith(Path.routes.root) && !anchorParent.hasAttribute("download") && !anchorParent.hasAttribute("external")) {
const mappedPath = Path.match(Path.routes.rootPath + anchorParent.href.slice(Path.routes.root.length), true);
if (mappedPath != null) {
if (anchorParent.hash && anchorParent.hash.startsWith("#!/"))
this.changePath(anchorParent.hash.substr(2));
else
this.changePath(App.removeRootPath(anchorParent.pathname));

e.stopPropagation();
e.preventDefault();
}
}
}

Expand Down

0 comments on commit 653355b

Please sign in to comment.