Skip to content

Commit

Permalink
Fix: Continue to display pills for matrix.to permalinks if a custom p…
Browse files Browse the repository at this point in the history
…ermalinkBaseUrl is set.
  • Loading branch information
nimau committed Apr 7, 2023
1 parent 0aef339 commit dadeef7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Riot/Modules/MatrixKit/Utils/MXKTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ + (void)initialize
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];
});
}
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Pills/PillType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}()

Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-7482.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Continue to display pills for matrix.to permalinks if a custom permalinkBaseUrl is set.

0 comments on commit dadeef7

Please sign in to comment.