Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Don’t intercept navigation to external URLs in Markdown
Thomas Scholtes committed 2 years ago
commit f80b193bbde1b535bbdfaf8ca61845aa4fdd600c
parent b797c6a3f728ed9b716a8bdb8066160adc1a3e51
2 files changed +17 -2
modified src/components/Markdown.svelte
@@ -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 {
modified tests/e2e/project.spec.ts
@@ -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/",
+
  );
+
});