mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
12 lines
395 B
TypeScript
12 lines
395 B
TypeScript
import open from "open"
|
|
|
|
export function openUrl(input: string) {
|
|
const url = URL.canParse(input) ? new URL(input) : undefined
|
|
if (!url || (url.protocol !== "http:" && url.protocol !== "https:"))
|
|
return Promise.reject(new Error(`Only http and https links can be opened in the browser: ${input}`))
|
|
return open(url.href)
|
|
}
|
|
|
|
export function openPath(path: string) {
|
|
return open(path)
|
|
}
|