summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Nachbaur <marionauta@users.noreply.github.com>2025-08-12 20:08:53 +0200
committerGitHub <noreply@github.com>2025-08-12 20:08:53 +0200
commit030d6e0f1177810e81ffddcf06c2c4a7ad32ed48 (patch)
tree8706a7c8517b9d5f6b32ffe846f87599246d13bc
parentdb3c3b77f59aa7cde7cf8487f8c587817ff38433 (diff)
Allow unicode letter characters in nicknames (#435)
-rw-r--r--bitchat/ViewModels/ChatViewModel.swift10
1 files changed, 5 insertions, 5 deletions
diff --git a/bitchat/ViewModels/ChatViewModel.swift b/bitchat/ViewModels/ChatViewModel.swift
index 0a216dc..5abed43 100644
--- a/bitchat/ViewModels/ChatViewModel.swift
+++ b/bitchat/ViewModels/ChatViewModel.swift
@@ -122,7 +122,7 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
// MARK: - Autocomplete Properties
// Autocomplete optimization
- private let mentionRegex = try? NSRegularExpression(pattern: "@([a-zA-Z0-9_]*)$", options: [])
+ private let mentionRegex = try? NSRegularExpression(pattern: "@([\\p{L}0-9_]*)$", options: [])
private var cachedNicknames: [String] = []
private var lastNicknameUpdate: Date = .distantPast
@@ -1652,7 +1652,7 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
var processedContent = AttributedString()
// Regular expressions for mentions and hashtags
- let mentionPattern = "@([a-zA-Z0-9_]+)"
+ let mentionPattern = "@([\\p{L}0-9_]+)"
let hashtagPattern = "#([a-zA-Z0-9_]+)"
let mentionRegex = try? NSRegularExpression(pattern: mentionPattern, options: [])
@@ -1751,7 +1751,7 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
let content = message.content
let hashtagPattern = "#([a-zA-Z0-9_]+)"
- let mentionPattern = "@([a-zA-Z0-9_]+)"
+ let mentionPattern = "@([\\p{L}0-9_]+)"
let hashtagRegex = try? NSRegularExpression(pattern: hashtagPattern, options: [])
let mentionRegex = try? NSRegularExpression(pattern: mentionPattern, options: [])
@@ -1876,7 +1876,7 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
var processedContent = AttributedString()
// Regular expression to find @mentions
- let pattern = "@([a-zA-Z0-9_]+)"
+ let pattern = "@([\\p{L}0-9_]+)"
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let matches = regex?.matches(in: contentText, options: [], range: NSRange(location: 0, length: contentText.count)) ?? []
@@ -3073,7 +3073,7 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
// MARK: - Helper Methods
private func parseMentions(from content: String) -> [String] {
- let pattern = "@([a-zA-Z0-9_]+)"
+ let pattern = "@([\\p{L}0-9_]+)"
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let matches = regex?.matches(in: content, options: [], range: NSRange(location: 0, length: content.count)) ?? []