Problem/Motivation
When putting an escape character in "Include links matching the pattern.": like with (.\.pdf|\/download)$
.
It works as an authenticated user because in extlink/js/extlink.js, the following code is executed:
if (drupalSettings.data.extlink.extInclude) {
extInclude = new RegExp(drupalSettings.data.extlink.extInclude.replace(/\\/, '\\'), 'i');
}
But for anonymous users, they end up into this return:
Drupal.extlink.attach = (context, drupalSettings) => {
if (typeof drupalSettings.data === 'undefined' || !drupalSettings.data.hasOwnProperty('extlink')) {
return;
}
So this is not properly replaced and provokes this error:
Uncaught SyntaxError: Bad escaped character in JSON at position 1410 (line 1 column 1411)
Steps to reproduce
In "Include links matching the pattern.", put: (.\.pdf|\/download)$
Go on the website as an anonymous user.
Proposed resolution
Checking why it is not directly in a Drupal behavior.
Remaining tasks
Find root cause and propose fix.