From b521797f4d3e238656c18df7c5842be3d5bd6c78 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 11 May 2021 22:28:14 +0530 Subject: [PATCH] Explain the reason for double escapes Signed-off-by: RMidhunSuresh --- src/domain/session/room/timeline/linkify/regex.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/linkify/regex.js b/src/domain/session/room/timeline/linkify/regex.js index a67ce415..b6e970cd 100644 --- a/src/domain/session/room/timeline/linkify/regex.js +++ b/src/domain/session/room/timeline/linkify/regex.js @@ -1,3 +1,8 @@ +/* +The regex is split into component strings; +meaning that any escapes (\) must be also +be escaped. +*/ const scheme = "(?:https|http|ftp):\\/\\/"; const host = "[a-zA-Z0-9:.\\[\\]-]"; @@ -24,7 +29,6 @@ Things to keep in mind: them in path or fragment components. https://matrix.org/ - valid https://matrix.org - invalid - 2. Do not treat punctuation at the end as a part of the URL (.,?!) */ const urlRegex = `${scheme}${host}+(?:${additional}|${endASCII})`;