Don’t intercept navigation to external URLs in Markdown

Fixes 928

Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
This commit is contained in:
Thomas Scholtes
2023-07-14 09:29:19 +02:00
committed by Rūdolfs Ošiņš
parent b797c6a3f7
commit f80b193bbd
2 changed files with 17 additions and 2 deletions
+4 -2
View File
@@ -45,8 +45,10 @@
return;
}
event.preventDefault();
void router.navigateToUrl("push", url);
if (url.origin === window.origin) {
event.preventDefault();
void router.navigateToUrl("push", url);
}
}
function render(content: string): string {
+13
View File
@@ -436,3 +436,16 @@ test.describe("browser error handling", () => {
await expect(page.locator("text=Not able to load file")).toBeVisible();
});
});
test("external markdown link", async ({ page }) => {
await page.route("http://github.github.com/**", route => {
return route.fulfill({ body: "hello", contentType: "text/plain" });
});
await page.goto(`${markdownUrl}/tree/main/cheatsheet.md`);
await page
.getByRole("link", { name: "Github-flavored Markdown info page" })
.click();
await expect(page).toHaveURL(
"http://github.github.com/github-flavored-markdown/",
);
});