From 31a5a8e8f1c181641f85f0263fae9eeeb614c283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Mon, 11 May 2020 00:05:22 +0200 Subject: [PATCH] Fix escaping of \ in character class. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Rejeté. Ce n'est pas un escape. D’après mes tests, c’est considéré comme un escape. Doubler le caractère serait suffisant. const url = 'https://example\\.com'; const urlRegexp1 = /https?:\/\/[-a-zA-Z0-9@:%/._\+~#=?]+[-a-zA-Z0-9@:%/_\+~#=]/g; const urlRegexp2 = /https?:\/\/[-a-zA-Z0-9@:%/._\\+~#=?]+[-a-zA-Z0-9@:%/_\\+~#=]/g; console.log(url.length); // 20 console.log(urlRegexp1.exec(url)); // ["https://example"] console.log(urlRegexp2.exec(url)); // ["https://example\.com"] --- static/sfu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/sfu.js b/static/sfu.js index c6f0f43..f0d0297 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -738,7 +738,7 @@ function gotPermissions(perm) { displayUsername(); } -const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\+~#=?]+[-a-zA-Z0-9@:%/_\+~#=]/g; +const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\\+~#=?]+[-a-zA-Z0-9@:%/_\\+~#=]/g; function formatLine(line) { let r = new RegExp(urlRegexp);