Merge pull request #350 from vector-im/bwindels/linkify-parenthesis

Don't accept closing parenthesis as last character of url
This commit is contained in:
Bruno Windels 2021-05-12 20:50:39 +00:00 committed by GitHub
commit 41f77f33af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -96,6 +96,12 @@ export function tests() {
}
},
"Link doesn't adopt closing parenthesis": assert => {
const link = "(https://matrix.org)";
const out = [{ type: "text", text: "(" }, { type: "link", text: "https://matrix.org" }, { type: "text", text: ")" }];
test(assert, link, out);
},
"Unicode in hostname must not linkify": assert => {
const link = "https://foo.bar\uD83D\uDE03.com";
const out = [{ type: "link", text: "https://foo.bar" },

View file

@ -4,7 +4,7 @@ meaning that any escapes (\) must also
be escaped.
*/
const scheme = "(?:https|http|ftp):\\/\\/";
const noSpaceNorPunctuation = "[^\\s.,?!]";
const noSpaceNorPunctuation = "[^\\s.,?!)]";
const hostCharacter = "[a-zA-Z0-9:.\\[\\]-]";
/*