From ef4e6b062ffb74db40131e4b4467cbcc348c82d1 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Mon, 17 Mar 2025 16:28:45 +0100 Subject: [PATCH] added a test to check if URLs work with RTL --- .../Sources/AttributedStringBuilderTests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift index fa21f00bc..1af255b28 100644 --- a/UnitTests/Sources/AttributedStringBuilderTests.swift +++ b/UnitTests/Sources/AttributedStringBuilderTests.swift @@ -745,6 +745,22 @@ class AttributedStringBuilderTests: XCTestCase { XCTAssertEqual(link.absoluteString, "https://matrix.org") } + func testValidLinkWithRTLOverride() { + let htmlString = "\u{202E}https://matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertFalse(link.requiresConfirmation) + XCTAssertEqual(link.absoluteString, "https://matrix.org") + } + func testPhishingUserID() { let htmlString = "Hey check the following user @alice:matrix.org"