diff --git a/src/pageScanner/checks/has-ambiguous-text.js b/src/pageScanner/checks/has-ambiguous-text.js index 828921372..4f122a098 100644 --- a/src/pageScanner/checks/has-ambiguous-text.js +++ b/src/pageScanner/checks/has-ambiguous-text.js @@ -23,12 +23,16 @@ const ambiguousPhrases = [ __( 'opens a new window', 'accessibility-checker' ), ]; +const normalizedPhrases = ambiguousPhrases.map( + ( p ) => p.toLowerCase().replace( /[^\p{L}]+/gu, ' ' ).trim() +); + const checkAmbiguousPhrase = ( text ) => { if ( ! text ) { return false; } - text = text.toLowerCase().replace( /[^a-z]+/g, ' ' ).trim(); - return ambiguousPhrases.includes( text ); + text = text.toLowerCase().replace( /[^\p{L}]+/gu, ' ' ).trim(); + return normalizedPhrases.includes( text ); }; export default {