You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OpenAsar-Kernel/src/utils/securityUtils.js

7 lines
387 B

const { shell } = require('electron');
const allowedProtocols = [ 'https', 'http' ]; // Only allow some protocols
exports.saferShellOpenExternal = (url) => allowedProtocols.includes(url.split(':')[0].toLowerCase()) ? shell.openExternal(url) : Promise.reject();
const oParse = (u) => u.split('/').slice(0, 3).join('/');
exports.checkUrlOriginMatches = (a, b) => oParse(a) === oParse(b);