mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 07:33:18 +00:00
* 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
22 lines
536 B
TypeScript
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);
|
|
}
|