Skip to content

Commit eb232bb

Browse files
Merge pull request #85 from contentful/fix/hyperlink-with-special-caracters
chore: fix hyperlink crash when it contains special characters like s…
2 parents 1f48d47 + 14fc15d commit eb232bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/RichTextRenderer/NodeRenderers/Hyperlink/HyperlinkRenderer.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ open class HyperlinkRenderer: NodeRendering {
2626
result.append(child)
2727
}
2828

29+
// Prevent crashes for links with spaces or other special characters
30+
let encodedURI = node.data.uri.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? node.data.uri
31+
2932
result.addAttributes(
3033
[
31-
.link: node.data.uri,
34+
.link: encodedURI,
3235
],
3336
range: result.fullRange
3437
)

0 commit comments

Comments
 (0)