mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-15 17:30:56 -05:00
12 lines
305 B
TypeScript
12 lines
305 B
TypeScript
|
const ALLOWED_PROTOCOLS = ['https:', 'http:']
|
||
|
|
||
|
export const openURL = (content: string) => {
|
||
|
const url = new URL(content, document.location.href)
|
||
|
|
||
|
if (!ALLOWED_PROTOCOLS.includes(url.protocol)) {
|
||
|
throw new Error(`Not opening URL with protocol ${url.protocol}`)
|
||
|
}
|
||
|
|
||
|
window.open(url, '_blank')
|
||
|
}
|