Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ios/Capacitor/Capacitor/Plugins/CapacitorCookieManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ public class CapacitorCookieManager {
}

public func getServerUrl() -> URL? {
return self.config?.serverURL ?? self.config?.localURL
guard let serverURL = self.config?.serverURL ?? self.config?.localURL else { return nil }
let assetHandlerScheme = self.config?.localURL.scheme ?? InstanceDescriptorDefaults.scheme
// If we're serving assets bundled with the app, then we need to change the scheme of the URL to
// https so that cookies marked secure are returned from HTTPCookieStorage.
if serverURL.scheme == assetHandlerScheme {
var components = URLComponents(url: serverURL, resolvingAgainstBaseURL: false)
components?.scheme = "https"
return components?.url
}
return serverURL
}

private func isUrlSanitized(_ urlString: String) -> Bool {
Expand Down