Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 8x 1x 6x 4x | // The window may show the app's own origin and nothing else.
export function isSameOrigin(url: string, appUrl: string): boolean {
return URL.canParse(url) && new URL(url).origin === new URL(appUrl).origin
}
const EXTERNAL_PROTOCOLS = new Set(['https:', 'mailto:'])
// A link in a message is someone else's text: only these schemes are handed to the system.
export function isSafeExternal(url: string): boolean {
return URL.canParse(url) && EXTERNAL_PROTOCOLS.has(new URL(url).protocol)
}
// Electron grants every permission unless told otherwise; Chattra only ever asks to notify.
export function isAllowedPermission(
permission: string,
requestingUrl: string,
appUrl: string,
): boolean {
return permission === 'notifications' && isSameOrigin(requestingUrl, appUrl)
}
|