Skip to content

Commit bd6d101

Browse files
committed
Gets rid of using deprecated String.Index(utf16Offset:in:) in URLComponents
1 parent 19a8e4e commit bd6d101

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Sources/Foundation/URLComponents.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,9 @@ public struct URLComponents : ReferenceConvertible, Hashable, Equatable, _Mutabl
184184
}
185185

186186
private func _toStringRange(_ r : NSRange) -> Range<String.Index>? {
187-
guard r.location != NSNotFound else { return nil }
188-
189-
let utf16Start = String.UTF16View.Index(encodedOffset: r.location)
190-
let utf16End = String.UTF16View.Index(encodedOffset: r.location + r.length)
191-
192-
guard let s = self.string else { return nil }
193-
guard let start = String.Index(utf16Start, within: s) else { return nil }
194-
guard let end = String.Index(utf16End, within: s) else { return nil }
195-
187+
guard let s = self.string, r.location != NSNotFound else { return nil }
188+
let start = String.Index(utf16Offset: r.location, in: s)
189+
let end = String.Index(utf16Offset: r.location + r.length, in: s)
196190
return start..<end
197191
}
198192

0 commit comments

Comments
 (0)