diff --git a/apps/client/src/features/editor/components/link/link-menu.tsx b/apps/client/src/features/editor/components/link/link-menu.tsx index e61a586c..4517a79d 100644 --- a/apps/client/src/features/editor/components/link/link-menu.tsx +++ b/apps/client/src/features/editor/components/link/link-menu.tsx @@ -5,7 +5,7 @@ import { useAtom } from "jotai"; import { isTextSelected } from "@docmost/editor-ext"; import { showLinkMenuAtom } from "@/features/editor/atoms/editor-atoms"; import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel"; -import { normalizeUrl } from "@/features/editor/components/link/link-view"; +import { normalizeUrl } from "@/lib/utils"; import { TextSelection } from "@tiptap/pm/state"; import { Paper } from "@mantine/core"; diff --git a/apps/client/src/features/editor/components/link/link-view.tsx b/apps/client/src/features/editor/components/link/link-view.tsx index 90b89e82..46227ef9 100644 --- a/apps/client/src/features/editor/components/link/link-view.tsx +++ b/apps/client/src/features/editor/components/link/link-view.tsx @@ -29,12 +29,7 @@ import { useSharePageQuery } from "@/features/share/queries/share-query.ts"; import { buildSharedPageUrl } from "@/features/page/page.utils.ts"; import { extractPageSlugId } from "@/lib"; import { sanitizeUrl, copyToClipboard } from "@docmost/editor-ext"; - -export const normalizeUrl = (url: string): string => { - if (!url) return url; - if (url.startsWith("/") || /^(\S+):(\/\/)?\S+$/.test(url)) return url; - return `https://${url}`; -}; +import { normalizeUrl } from "@/lib/utils"; const parseInternalLink = ( href: string, diff --git a/apps/client/src/lib/utils.tsx b/apps/client/src/lib/utils.tsx index e9c39267..b5da9c7a 100644 --- a/apps/client/src/lib/utils.tsx +++ b/apps/client/src/lib/utils.tsx @@ -94,6 +94,12 @@ export function getPageIcon(icon: string, size = 18): string | ReactNode { ); } +export const normalizeUrl = (url: string): string => { + if (!url) return url; + if (url.startsWith("/") || /^(\S+):(\/\/)?\S+$/.test(url)) return url; + return `https://${url}`; +}; + export function castToBoolean(value: unknown): boolean { if (value == null) { return false;