diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/Share-with-Bluesky/ShareViewController.swift | 2 | ||||
-rw-r--r-- | modules/react-native-ui-text-view/ios/RNUITextView.swift | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/modules/Share-with-Bluesky/ShareViewController.swift b/modules/Share-with-Bluesky/ShareViewController.swift index a16a290bf..4c1d635ce 100644 --- a/modules/Share-with-Bluesky/ShareViewController.swift +++ b/modules/Share-with-Bluesky/ShareViewController.swift @@ -119,7 +119,7 @@ class ShareViewController: UIViewController { // extension does. if let dir = FileManager() .containerURL( - forSecurityApplicationGroupIdentifier: "group.\(Bundle.main.bundleIdentifier?.replacingOccurrences(of: ".Share-with-Bluesky", with: "") ?? "")") + forSecurityApplicationGroupIdentifier: "group.app.bsky") { let filePath = "\(dir.absoluteString)\(ProcessInfo.processInfo.globallyUniqueString).jpeg" diff --git a/modules/react-native-ui-text-view/ios/RNUITextView.swift b/modules/react-native-ui-text-view/ios/RNUITextView.swift index 9c21d45b5..3fb55873d 100644 --- a/modules/react-native-ui-text-view/ios/RNUITextView.swift +++ b/modules/react-native-ui-text-view/ios/RNUITextView.swift @@ -108,14 +108,26 @@ class RNUITextView: UIView { fractionOfDistanceBetweenInsertionPoints: nil ) + var lastUpperBound: String.Index? = nil for child in self.reactSubviews() { if let child = child as? RNUITextViewChild, let childText = child.text { let fullText = self.textView.attributedText.string - let range = fullText.range(of: childText) - + + // We want to skip over the children we have already checked, otherwise we could run into + // collisions of similar strings (i.e. links that get shortened to the same hostname but + // different paths) + let range = fullText.range(of: childText, options: [], range: (lastUpperBound ?? String.Index(utf16Offset: 0, in: fullText) )..<fullText.endIndex) + if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound { - if charIndex >= lowerBound.utf16Offset(in: fullText) && charIndex <= upperBound.utf16Offset(in: fullText) { + let lowerOffset = lowerBound.utf16Offset(in: fullText) + let upperOffset = upperBound.utf16Offset(in: fullText) + + if charIndex >= lowerOffset, + charIndex <= upperOffset + { return child + } else { + lastUpperBound = upperBound } } } |