hotfix use custom url scheme to open links if provided

This commit is contained in:
JanNiklas Grabowski
2023-12-22 12:25:59 +01:00
parent 59ee43ed5c
commit 5decccf6cb
18 changed files with 106 additions and 22 deletions
+9
View File
@@ -419,4 +419,13 @@ manualChangeMessageForVideo:(NSString*)manualChangeMessageForVideo
*/
+ (NSString*)logForPushToken:(NSData*)pushToken;
#pragma mark - bwi
/**
Check if link is a permalink.
@param link the link to ceck.
@return true if link is a permalink, false if it is not a permalink.
*/
+ (BOOL)isLinkPermalink:(NSString*)link;
@end
+16
View File
@@ -1079,8 +1079,10 @@ manualChangeMessageForVideo:(NSString*)manualChangeMessageForVideo
NSRange matchRange = [match range];
NSURL *matchUrl = [match URL];
NSURLComponents *url = [[NSURLComponents new] initWithURL:matchUrl resolvingAgainstBaseURL:NO];
url = [CustomURLSchemeHelper.shared overrideURLSchemeIfNeeded:url];
if (url.URL)
{
[mutableAttributedString addAttribute:NSLinkAttributeName value:url.URL range:matchRange];
[mutableAttributedString addAttribute:NSForegroundColorAttributeName value:ThemeService.shared.theme.colors.links range:matchRange];
}
}
@@ -1254,4 +1256,18 @@ manualChangeMessageForVideo:(NSString*)manualChangeMessageForVideo
return [NSString stringWithFormat:@"%@...", [pushToken subdataWithRange:NSMakeRange(0, len)]];
}
#pragma mark - bwi
+ (BOOL)isLinkPermalink:(NSString*)link
{
if ([permalinkRegex numberOfMatchesInString:link options:0 range:NSMakeRange(0, link.length)] == 0)
{
return NO;
}
else
{
return YES;
}
}
@end