File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ open class HTTPCookieStorage: NSObject {
47
47
allCookies = [ : ]
48
48
cookieAcceptPolicy = . always
49
49
super. init ( )
50
- cookieFilePath = filePath ( path: _CFXDGCreateConfigHomePath ( ) . _swiftObject, fileName: " /.cookies. " + cookieStorageName)
50
+ cookieFilePath = filePath ( path: _CFXDGCreateDataHomePath ( ) . _swiftObject, fileName: " /.cookies. " + cookieStorageName)
51
51
loadPersistedCookies ( )
52
52
}
53
53
@@ -65,7 +65,7 @@ open class HTTPCookieStorage: NSObject {
65
65
guard !FileManager. default. fileExists ( atPath: path) else { return true }
66
66
67
67
do {
68
- try FileManager . default. createDirectory ( atPath: path, withIntermediateDirectories: false , attributes: nil )
68
+ try FileManager . default. createDirectory ( atPath: path, withIntermediateDirectories: true , attributes: nil )
69
69
return true
70
70
} catch {
71
71
return false
@@ -77,7 +77,7 @@ open class HTTPCookieStorage: NSObject {
77
77
return path + fileName
78
78
}
79
79
//if we were unable to create the desired directory, create the cookie file in the `pwd`
80
- return fileName
80
+ return FileManager . default . currentDirectoryPath + fileName
81
81
}
82
82
83
83
open var cookies : [ HTTPCookie ] ? {
Original file line number Diff line number Diff line change @@ -227,10 +227,10 @@ class TestNSHTTPCookieStorage: XCTestCase {
227
227
storage. setCookie ( testCookie)
228
228
XCTAssertEqual ( storage. cookies!. count, 3 )
229
229
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 "
232
232
} else {
233
- destPath = NSHomeDirectory ( ) + " /.config /.cookies.shared "
233
+ destPath = NSHomeDirectory ( ) + " /.local/share /.cookies.shared "
234
234
}
235
235
let fm = FileManager . default
236
236
var isDir = false
@@ -243,7 +243,7 @@ class TestNSHTTPCookieStorage: XCTestCase {
243
243
let task = Process ( )
244
244
task. launchPath = bundlePath. substring ( to: pathIndex!) + " /xdgTestHelper/xdgTestHelper "
245
245
var environment = ProcessInfo . processInfo. environment
246
- environment [ " XDG_CONFIG_HOME " ] = NSHomeDirectory ( ) + " /TestXDG "
246
+ environment [ " XDG_DATA_HOME " ] = NSHomeDirectory ( ) + " /TestXDG "
247
247
task. environment = environment
248
248
// Launch the task
249
249
task. launch ( )
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ let simpleCookie = HTTPCookie(properties: [
7
7
. path: " / " ,
8
8
. domain: " example.com " ,
9
9
] ) !
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!)
12
12
storage. setCookie ( simpleCookie)
13
13
let fm = FileManager . default
14
- let destPath = xdg_config_home ! + " /.cookies.shared "
14
+ let destPath = xdg_data_home ! + " /.cookies.shared "
15
15
var isDir = false
16
16
let exists = fm. fileExists ( atPath: destPath, isDirectory: & isDir)
17
17
if ( !exists) {
You can’t perform that action at this time.
0 commit comments