mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
e7827fbd57
GitOrigin-RevId: 1da255d3e8ccd91e8c8774d140ec663906be948f
11 lines
305 B
TypeScript
11 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')
|
|
}
|