Skip to content

Commit 69a8ecd

Browse files
authored
Merge pull request #2832 from valeriyvan/URLComponents
Gets rid of using deprecated String.Index(utf16Offset:in:)
2 parents 61f1372 + bd6d101 commit 69a8ecd

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)