-
-
Notifications
You must be signed in to change notification settings - Fork 526
Open
Description
I'm using the helper function below to ease specifying the URL without having to escape etc. Should this be a built in function? Seems like a such a common use case, and is unnecessarily complicated for beginners.
// this works,
// settings.blocklistPattern = /.*mail\.google\.com.*|.*catanuniverse\.com.*|.*gist\.github\.com.*|.*excel\.officeapps\.live\.com.*|.*hp\.sharepoint\.com.*/
function createBlocklistPattern(urls) {
const escapedPatterns = urls.map(url =>
`.*${url.replace(/\./g, '\\.')}.*`
);
return new RegExp(escapedPatterns.join('|'));
}
const urlList = [
'google.com',
'catanuniverse.com',
'gist.github.com',
'excel.officeapps.live.com',
'hp.sharepoint.com'
];
settings.blocklistPattern = createBlocklistPattern(urlList);
// does not work,
// settings.blacklistPattern = /.*mail.google.com.*|.*inbox.google.com.*|trello.com|duolingo.com|youtube.com|udemy.com|localhost/i;
// settings.blocklistPattern = /((calendar|mail).google|trello|duolingo|youtube|udemy).com/i
Metadata
Metadata
Assignees
Labels
No labels