Compare commits

...

3 Commits

Author SHA1 Message Date
Ludeeus
5e10d85f50 Console.Die 2021-02-16 17:14:19 +00:00
Ludeeus
d9283c17eb use startsWith 2021-02-16 17:11:09 +00:00
Ludeeus
dbc3bc81a7 Rewrite my links in markdown-element 2021-02-16 17:07:56 +00:00

View File

@@ -41,8 +41,24 @@ class HaMarkdownElement extends UpdatingElement {
while (walker.nextNode()) {
const node = walker.currentNode;
// Open external links in a new window
// Handle my.home-assistant.io links
if (
node instanceof HTMLAnchorElement &&
node.host === "my.home-assistant.io"
) {
const hrefNodes = node.href.split("/");
if (document.location.pathname.startsWith("/hassio")) {
node.target = "_parent";
} else {
node.target = "_self";
}
node.href = `/_my_redirect/${hrefNodes
.slice(4, hrefNodes.length)
.join("/")}`;
}
// Open external links in a new window
else if (
node instanceof HTMLAnchorElement &&
node.host !== document.location.host
) {