Skip to content
Snippets Groups Projects
Commit 88af7e12 authored by David Byers's avatar David Byers
Browse files

Added docstrings, updated messages.

parent 3b9f5166
No related branches found
No related tags found
1 merge request!13Added docstrings, updated messages.
Pipeline #38640 passed
{
"extensionDescription": {
"message": "Correct the display and quoting of links mangled by Microsoft Defender for Office 365 Safe Links.",
"message": "Correct the display and quoting of links mangled by Microsoft Defender for Office 365 Safe Links or Barracuda Link Protection.",
"description": "Description of the extension."
},
......
{
"extensionDescription": {
"message": "Korrigera visning och citering av länkar manglade av Microsoft Defender för Office 365 Safe Links.",
"message": "Korrigera visning och citering av länkar manglade av Microsoft Defender för Office 365 Safe Links eller Barracuda Link Protection.",
"description": "Description of the extension."
},
......
......@@ -25,23 +25,52 @@
const safelinksPatterns = [
{
name: 'Microsoft Defender For Office 365 Safe Links',
host: '*.safelinks.protection.outlook.com',
path: '[?]url=([^&]+).*'
},
{
name: 'Barracuda Link Protection',
host: 'linkprotect.cudasvc.com',
path: 'url[?]a=([^&]+).*'
},
{
name: 'Proofpoint (v3)',
host: 'urldefense.com',
path: 'v3/_+([^_]+).*'
}
// {
// name: 'Proofpoint (v2)',
// host: 'urldefense.proofpoint.com',
// path: 'v2/url[?]u=([^&]+).*',
// proc: (string) => string.replace('_', '/')
// }
];
/**
* Compute a list of url patterns from the link patterns.
* @returns {Array} - Array of patterns.
*/
function computeSafelinksMatchPatterns() {
return safelinksPatterns.map(({host, path}) => '*://' + host + '/*');
}
/**
* Escape a hostname pattern for use in a regexp.
* @param {string} host - The host name pattern.
* @returns {string} A suitable regexp.
*/
function escapeHostname(host) {
return host.replace('.', '[.]').replace('*', '[^/]*')
}
/**
* Compute a regexp that matches all mangled links.
* @returns {RegExp} A regexp that matches all possible mangled links.
*/
function computeSafelinksRegexp() {
return new RegExp('(?:' +
safelinksPatterns.map(
......@@ -51,4 +80,5 @@ function computeSafelinksRegexp() {
'gi');
}
const safelinksRegexp = computeSafelinksRegexp()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment