Files
paseo/packages/app/src/utils/open-external-url.ts
T
Mohamed Boudra c7db3c5a8c Let plugins open external links and workspace browsers (#4972)
* feat(plugins): open external links and workspace browsers

* fix(plugins): refuse invalid links and unavailable browser workspaces

* docs(plugins): clarify external links and browser navigation
2026-09-16 23:25:17 +02:00

22 lines
536 B
TypeScript

import * as Linking from "expo-linking";
import { getDesktopHost } from "@/desktop/host";
import { isWeb } from "@/constants/platform";
import { isHttpUrl } from "./http-url";
export async function openExternalUrl(url: string): Promise<void> {
if (!isHttpUrl(url)) return;
if (isWeb) {
const opener = getDesktopHost()?.opener?.openUrl;
if (typeof opener === "function") {
await opener(url);
return;
}
window.open(url, "_blank", "noopener,noreferrer");
return;
}
await Linking.openURL(url);
}