Skip to content

Commit c0ed4e8

Browse files
authored
Merge pull request #1177 from ianpartridge/substring-warnings
2 parents 5408cfe + dc409ae commit c0ed4e8

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Foundation/HTTPCookieStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ open class HTTPCookieStorage: NSObject {
4949
let bundlePath = Bundle.main.bundlePath
5050
var bundleName = bundlePath.components(separatedBy: "/").last!
5151
if let range = bundleName.range(of: ".", options: String.CompareOptions.backwards, range: nil, locale: nil) {
52-
bundleName = bundleName.substring(to: range.lowerBound)
52+
bundleName = String(bundleName[..<range.lowerBound])
5353
}
5454
let cookieFolderPath = _CFXDGCreateDataHomePath()._swiftObject + "/" + bundleName
5555
cookieFilePath = filePath(path: cookieFolderPath, fileName: "/.cookies." + cookieStorageName, bundleName: bundleName)

TestFoundation/TestHTTPCookieStorage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class TestHTTPCookieStorage: XCTestCase {
230230
let bundlePath = Bundle.main.bundlePath
231231
var bundleName = "/" + bundlePath.components(separatedBy: "/").last!
232232
if let range = bundleName.range(of: ".", options: String.CompareOptions.backwards, range: nil, locale: nil) {
233-
bundleName = bundleName.substring(to: range.lowerBound)
233+
bundleName = String(bundleName[..<range.lowerBound])
234234
}
235235
if let xdg_data_home = getenv("XDG_DATA_HOME") {
236236
destPath = String(utf8String: xdg_data_home)! + bundleName + "/.cookies.shared"
@@ -251,7 +251,7 @@ class TestHTTPCookieStorage: XCTestCase {
251251
let exeName = "/xdgTestHelper/xdgTestHelper"
252252
#endif
253253

254-
task.launchPath = bundlePath.substring(to: pathIndex!) + exeName
254+
task.launchPath = bundlePath[..<pathIndex!] + exeName
255255
var environment = ProcessInfo.processInfo.environment
256256
let testPath = NSHomeDirectory() + "/TestXDG"
257257
environment["XDG_DATA_HOME"] = testPath

TestFoundation/TestProcess.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private func parseEnv(_ env: String) throws -> [String: String] {
334334
guard let range = line.range(of: "=") else {
335335
throw Error.InvalidEnvironmentVariable(line)
336336
}
337-
result[line.substring(to: range.lowerBound)] = line.substring(from: range.upperBound)
337+
result[String(line[..<range.lowerBound])] = String(line[range.upperBound...])
338338
}
339339
return result
340340
}

TestFoundation/TestXMLParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ class TestXMLParser : XCTestCase {
8686
return xmlUnderTest
8787
}
8888
if let open = encoding.range(of: "(") {
89-
encoding = encoding.substring(from: open.upperBound)
89+
encoding = String(encoding[open.upperBound...])
9090
}
9191
if let close = encoding.range(of: ")") {
92-
encoding = encoding.substring(to: close.lowerBound)
92+
encoding = String(encoding[..<close.lowerBound])
9393
}
9494
return "<?xml version='1.0' encoding='\(encoding.uppercased())' standalone='no'?>\n\(xmlUnderTest)\n"
9595
}

0 commit comments

Comments
 (0)