fix: Internal URL detection on client, closes #7245

This commit is contained in:
Tom Moor committed 2024-09-14 11:46:42 -04:00
1 parent e6ba84e434
commit 5116147ace
2 files changed
+7 -1

No files matched your search

+4
View File
@@ -59,6 +59,10 @@ describe("isInternalUrl", () => {
expect(urlsUtils.isInternalUrl("https://example.com:4000")).toBe(false);
});
it("should return false if port is missing", () => {
expect(urlsUtils.isInternalUrl("https://example.com")).toBe(false);
});
it("should return true if starting with relative path", () => {
expect(urlsUtils.isInternalUrl("/drafts")).toEqual(true);
});
+3 -1
View File
@@ -37,7 +37,9 @@ export function isInternalUrl(href: string) {
return (
(outline.host === domain.host && outline.port === domain.port) ||
(typeof window !== "undefined" && window.location.hostname === domain.host)
(typeof window !== "undefined" &&
window.location.hostname === domain.host &&
window.location.port === domain.port)
);
}