Skip to content

Commit 667dde1

Browse files
authored
Merge pull request #1000 from mamabusi/storeCookieInDataHome
2 parents dc3764f + b1ccf49 commit 667dde1

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Foundation/NSHTTPCookieStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ open class HTTPCookieStorage: NSObject {
4747
allCookies = [:]
4848
cookieAcceptPolicy = .always
4949
super.init()
50-
cookieFilePath = filePath(path: _CFXDGCreateConfigHomePath()._swiftObject, fileName: "/.cookies." + cookieStorageName)
50+
cookieFilePath = filePath(path: _CFXDGCreateDataHomePath()._swiftObject, fileName: "/.cookies." + cookieStorageName)
5151
loadPersistedCookies()
5252
}
5353

TestFoundation/TestNSHTTPCookieStorage.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ class TestNSHTTPCookieStorage: XCTestCase {
227227
storage.setCookie(testCookie)
228228
XCTAssertEqual(storage.cookies!.count, 3)
229229
var destPath: String
230-
if let xdg_config_home = getenv("XDG_CONFIG_HOME") {
231-
destPath = String(utf8String: xdg_config_home)! + "/.cookies.shared"
230+
if let xdg_data_home = getenv("XDG_DATA_HOME") {
231+
destPath = String(utf8String: xdg_data_home)! + "/.cookies.shared"
232232
} else {
233-
destPath = NSHomeDirectory() + "/.config/.cookies.shared"
233+
destPath = NSHomeDirectory() + "/.local/share/.cookies.shared"
234234
}
235235
let fm = FileManager.default
236236
var isDir = false
@@ -243,7 +243,7 @@ class TestNSHTTPCookieStorage: XCTestCase {
243243
let task = Process()
244244
task.launchPath = bundlePath.substring(to: pathIndex!) + "/xdgTestHelper/xdgTestHelper"
245245
var environment = ProcessInfo.processInfo.environment
246-
environment["XDG_CONFIG_HOME"] = NSHomeDirectory() + "/TestXDG"
246+
environment["XDG_DATA_HOME"] = NSHomeDirectory() + "/TestXDG"
247247
task.environment = environment
248248
// Launch the task
249249
task.launch()

TestFoundation/XDGTestHelper.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ let simpleCookie = HTTPCookie(properties: [
77
.path: "/",
88
.domain: "example.com",
99
])!
10-
let rawValue = getenv("XDG_CONFIG_HOME")
11-
let xdg_config_home = String(utf8String: rawValue!)
10+
let rawValue = getenv("XDG_DATA_HOME")
11+
let xdg_data_home = String(utf8String: rawValue!)
1212
storage.setCookie(simpleCookie)
1313
let fm = FileManager.default
14-
let destPath = xdg_config_home! + "/.cookies.shared"
14+
let destPath = xdg_data_home! + "/.cookies.shared"
1515
var isDir = false
1616
let exists = fm.fileExists(atPath: destPath, isDirectory: &isDir)
1717
if (!exists) {

0 commit comments

Comments
 (0)