Improve link regex to fix handling paranthesis and question marks
This patch fixes two key issues: * `?` is considered part of the URL, even if there might not be anything past it. I've seen people now putting spaces after URLs to get around this issue. * `)` is also part of the URL, as well as `:` despite those not being valid characters at the end of URLs.
This commit is contained in:
committed by
Tobias Fella
parent
31fed8362a
commit
0af420b824
@@ -17,7 +17,7 @@ TextEdit {
|
||||
property bool isEmote: false
|
||||
property bool isReplyLabel: false
|
||||
|
||||
readonly property var linkRegex: /(href=["'])?(\b(https?):\/\/[^\s\<\>\"\'\\]+)/g
|
||||
readonly property var linkRegex: /(href=["'])?(\b(https?):\/\/[^\s\<\>\"\'\\\?\:\)\(]+(\(.*?\))*(\?(?=[a-z])[^\s\\\)]+|$)?)/g
|
||||
property string textMessage: model.display.includes("http")
|
||||
? model.display.replace(linkRegex, function() {
|
||||
if (arguments[0].includes("/_matrix/media/r0/download/")) {
|
||||
|
||||
Reference in New Issue
Block a user