mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Validate URL protocol before opening from Visual Editor tooltip (#18393)
GitOrigin-RevId: 1da255d3e8ccd91e8c8774d140ec663906be948f
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
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')
|
||||
}
|
||||
Reference in New Issue
Block a user