From 71e2fac91bda884d9dd30799d9c60cb1a603120d Mon Sep 17 00:00:00 2001 From: Denny Biasiolli Date: Fri, 21 May 2021 16:12:09 +0200 Subject: [PATCH] fixing regex pattern including dashes in email domain addresses --- src/built-ins/simple-regexp-patterns.ts | 2 +- test/redactor.test.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/built-ins/simple-regexp-patterns.ts b/src/built-ins/simple-regexp-patterns.ts index c43ec61..26fb661 100644 --- a/src/built-ins/simple-regexp-patterns.ts +++ b/src/built-ins/simple-regexp-patterns.ts @@ -11,7 +11,7 @@ export const zipcode = /\b\d{5}\b(-\d{4})?\b/g; export const phoneNumber = /(\(?\+?[0-9]{1,2}\)?[-. ]?)?(\(?[0-9]{3}\)?|[0-9]{3})[-. ]?([0-9]{3}[-. ]?[0-9]{4}|\b[A-Z0-9]{7}\b)/g; export const ipAddress = /(\d{1,3}(\.\d{1,3}){3}|[0-9A-F]{4}(:[0-9A-F]{4}){5}(::|(:0000)+))/gi; export const usSocialSecurityNumber = /\b\d{3}[ -.]\d{2}[ -.]\d{4}\b/g; -export const emailAddress = /([a-z0-9_\-.+]+)@\w+(\.\w+)*/gi; +export const emailAddress = /([a-z0-9_\-.+]+)@[\w\-]+(\.\w+)*/gi; export const username = /(user( ?name)?|login): \S+/gi; export const password = /(pass(word|phrase)?|secret): \S+/gi; export const credentials = /(login( cred(ential)?s| info(rmation)?)?|cred(ential)?s) ?:\s*\S+\s+\/?\s*\S+/gi; diff --git a/test/redactor.test.ts b/test/redactor.test.ts index ba5322c..a5982ee 100644 --- a/test/redactor.test.ts +++ b/test/redactor.test.ts @@ -144,7 +144,8 @@ describe('index.js', function() { TestCase('should replace email addresses', [ ['my email: joe123@solvvy.co.uk.', 'my email: EMAIL_ADDRESS.'], - ['my email is other+foobar@t.co.', 'my email is EMAIL_ADDRESS.'] + ['my email is other+foobar@t.co.', 'my email is EMAIL_ADDRESS.'], + ['my email is other+foobar@t-bbb.co.', 'my email is EMAIL_ADDRESS.'], ]); TestCase('should replace street addresses', [