Merge pull request #1295 from bagedevimo/allow-no-domain
Allow a cookie without a domain to be set on Android
This commit is contained in:
commit
069594a8cf
|
@ -140,7 +140,10 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
|
|||
cookieManager = getCookieManager();
|
||||
if (cookieManager == null) return;
|
||||
|
||||
String cookieValue = name + "=" + value + "; Domain=" + domain + "; Path=" + path;
|
||||
String cookieValue = name + "=" + value + "; Path=" + path;
|
||||
|
||||
if (domain != null)
|
||||
cookieValue += "; Domain=" + domain;
|
||||
|
||||
if (expiresDate != null)
|
||||
cookieValue += "; Expires=" + getCookieExpirationDate(expiresDate);
|
||||
|
|
|
@ -35,7 +35,6 @@ class MyCookieManager: NSObject, FlutterPlugin {
|
|||
let url = arguments!["url"] as! String
|
||||
let name = arguments!["name"] as! String
|
||||
let value = arguments!["value"] as! String
|
||||
let domain = arguments!["domain"] as! String
|
||||
let path = arguments!["path"] as! String
|
||||
|
||||
var expiresDate: Int64?
|
||||
|
@ -47,12 +46,13 @@ class MyCookieManager: NSObject, FlutterPlugin {
|
|||
let isSecure = arguments!["isSecure"] as? Bool
|
||||
let isHttpOnly = arguments!["isHttpOnly"] as? Bool
|
||||
let sameSite = arguments!["sameSite"] as? String
|
||||
let domain = arguments!["domain"] as? String
|
||||
|
||||
MyCookieManager.setCookie(url: url,
|
||||
name: name,
|
||||
value: value,
|
||||
domain: domain,
|
||||
path: path,
|
||||
domain: domain,
|
||||
expiresDate: expiresDate,
|
||||
maxAge: maxAge,
|
||||
isSecure: isSecure,
|
||||
|
@ -92,8 +92,8 @@ class MyCookieManager: NSObject, FlutterPlugin {
|
|||
public static func setCookie(url: String,
|
||||
name: String,
|
||||
value: String,
|
||||
domain: String,
|
||||
path: String,
|
||||
domain: String?,
|
||||
expiresDate: Int64?,
|
||||
maxAge: Int64?,
|
||||
isSecure: Bool?,
|
||||
|
@ -109,8 +109,12 @@ class MyCookieManager: NSObject, FlutterPlugin {
|
|||
properties[.originURL] = url
|
||||
properties[.name] = name
|
||||
properties[.value] = value
|
||||
properties[.domain] = domain
|
||||
properties[.path] = path
|
||||
|
||||
if domain != nil {
|
||||
properties[.domain] = domain
|
||||
}
|
||||
|
||||
if expiresDate != nil {
|
||||
// convert from milliseconds
|
||||
properties[.expires] = Date(timeIntervalSince1970: TimeInterval(Double(expiresDate!)/1000))
|
||||
|
|
|
@ -63,12 +63,9 @@ class CookieManager {
|
|||
bool? isHttpOnly,
|
||||
HTTPCookieSameSitePolicy? sameSite,
|
||||
InAppWebViewController? iosBelow11WebViewController}) async {
|
||||
if (domain == null) domain = _getDomainName(url);
|
||||
|
||||
assert(url.toString().isNotEmpty);
|
||||
assert(name.isNotEmpty);
|
||||
assert(value.isNotEmpty);
|
||||
assert(domain.isNotEmpty);
|
||||
assert(path.isNotEmpty);
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.iOS) {
|
||||
|
@ -109,15 +106,16 @@ class CookieManager {
|
|||
{required Uri url,
|
||||
required String name,
|
||||
required String value,
|
||||
required String domain,
|
||||
String path = "/",
|
||||
String? domain,
|
||||
int? expiresDate,
|
||||
int? maxAge,
|
||||
bool? isSecure,
|
||||
HTTPCookieSameSitePolicy? sameSite,
|
||||
InAppWebViewController? webViewController}) async {
|
||||
var cookieValue =
|
||||
name + "=" + value + "; Domain=" + domain + "; Path=" + path;
|
||||
var cookieValue = name + "=" + value + "; Path=" + path;
|
||||
|
||||
if (domain != null) cookieValue += "; Domain=" + domain;
|
||||
|
||||
if (expiresDate != null)
|
||||
cookieValue += "; Expires=" + await _getCookieExpirationDate(expiresDate);
|
||||
|
|
Loading…
Reference in New Issue