diff --git a/Riot/Modules/MatrixKit/Utils/MXKTools.m b/Riot/Modules/MatrixKit/Utils/MXKTools.m index 3af8ef1fd..c993d0832 100644 --- a/Riot/Modules/MatrixKit/Utils/MXKTools.m +++ b/Riot/Modules/MatrixKit/Utils/MXKTools.m @@ -69,8 +69,9 @@ static NSRegularExpression* permalinkRegex; httpLinksRegex = [NSRegularExpression regularExpressionWithPattern:@"(?i)\\b(https?://\\S*)\\b" options:NSRegularExpressionCaseInsensitive error:nil]; htmlTagsRegex = [NSRegularExpression regularExpressionWithPattern:@"<(\\w+)[^>]*>" options:NSRegularExpressionCaseInsensitive error:nil]; linkDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil]; - - NSString *permalinkPattern = [NSString stringWithFormat:@"%@%@", BuildSettings.clientPermalinkBaseUrl ?: kMXMatrixDotToUrl, kMXKToolsRegexStringForPermalink]; + + // if we have a custom clientPermalinkBaseUrl, we also need to support matrix.to permalinks + NSString *permalinkPattern = [NSString stringWithFormat:@"(?:%@|%@)%@", BuildSettings.clientPermalinkBaseUrl, kMXMatrixDotToUrl, kMXKToolsRegexStringForPermalink]; permalinkRegex = [NSRegularExpression regularExpressionWithPattern:permalinkPattern options:NSRegularExpressionCaseInsensitive error:nil]; }); } diff --git a/Riot/Modules/Pills/PillType.swift b/Riot/Modules/Pills/PillType.swift index 8b90de15b..53b42e0e2 100644 --- a/Riot/Modules/Pills/PillType.swift +++ b/Riot/Modules/Pills/PillType.swift @@ -27,7 +27,7 @@ enum PillType: Codable { extension PillType { private static var regexPermalinkTarget: NSRegularExpression? = { let clientBaseUrl = BuildSettings.clientPermalinkBaseUrl ?? kMXMatrixDotToUrl - let pattern = #"\#(clientBaseUrl)/#/(?:(?:room|user)/)?((?:@|!|#)[^@!#/?\s]*)/?((?:\$)[^\$/?\s]*)?"# + let pattern = #"(?:\#(clientBaseUrl)|\#(kMXMatrixDotToUrl))/#/(?:(?:room|user)/)?((?:@|!|#)[^@!#/?\s]*)/?((?:\$)[^\$/?\s]*)?"# return try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) }() diff --git a/changelog.d/pr-7482.bugfix b/changelog.d/pr-7482.bugfix new file mode 100644 index 000000000..842d621b2 --- /dev/null +++ b/changelog.d/pr-7482.bugfix @@ -0,0 +1 @@ +Continue to display pills for matrix.to permalinks if a custom permalinkBaseUrl is set.