@capacitor/ios 7.6.0 → 7.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- (NSString * _Nullable)getString:(NSString * _Nonnull)key defaultValue:(NSString * _Nullable)defaultValue;
|
|
11
11
|
- (NSDate * _Nullable)getDate:(NSString * _Nonnull)key defaultValue:(NSDate * _Nullable)defaultValue;
|
|
12
12
|
- (NSDictionary * _Nullable)getObject:(NSString * _Nonnull)key defaultValue:(NSDictionary * _Nullable)defaultValue;
|
|
13
|
+
- (NSArray * _Nullable)getArray:(NSString * _Nonnull)key defaultValue:(NSArray * _Nullable)defaultValue;
|
|
13
14
|
- (NSNumber * _Nullable)getNumber:(NSString * _Nonnull)key defaultValue:(NSNumber * _Nullable)defaultValue;
|
|
14
15
|
- (BOOL)getBool:(NSString * _Nonnull)key defaultValue:(BOOL)defaultValue;
|
|
15
16
|
@end
|
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
return defaultValue;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
- (NSArray * _Nullable)getArray:(NSString * _Nonnull)key defaultValue:(NSArray * _Nullable)defaultValue; {
|
|
33
|
+
id value = [[self dictionaryRepresentation] objectForKey:key];
|
|
34
|
+
if (value != nil && [value isKindOfClass:[NSArray class]]) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
return defaultValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
- (NSNumber * _Nullable)getNumber:(NSString * _Nonnull)key defaultValue:(NSNumber * _Nullable)defaultValue {
|
|
33
41
|
id value = [[self dictionaryRepresentation] objectForKey:key];
|
|
34
42
|
if (value != nil && [value isKindOfClass:[NSNumber class]]) {
|
|
@@ -66,7 +66,7 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
|
|
|
66
66
|
|
|
67
67
|
var data = Data()
|
|
68
68
|
var boundary = UUID().uuidString
|
|
69
|
-
if contentType.contains("="), let contentBoundary =
|
|
69
|
+
if contentType.contains("boundary="), let contentBoundary = extractBoundary(from: contentType) {
|
|
70
70
|
boundary = contentBoundary
|
|
71
71
|
} else {
|
|
72
72
|
overrideContentType(boundary)
|
|
@@ -86,6 +86,27 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
|
|
|
86
86
|
request.setValue(contentType, forHTTPHeaderField: "Content-Type")
|
|
87
87
|
headers["Content-Type"] = contentType
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
Extracts the boundary value of the `content-type` header for multiplart/form-data requests, if provided
|
|
92
|
+
The boundary value might be surrounded by double quotes (") which will be stripped away.
|
|
93
|
+
*/
|
|
94
|
+
private func extractBoundary(from contentType: String) -> String? {
|
|
95
|
+
if let boundaryRange = contentType.range(of: "boundary=") {
|
|
96
|
+
var boundary = contentType[boundaryRange.upperBound...]
|
|
97
|
+
if let endRange = boundary.range(of: ";") {
|
|
98
|
+
boundary = boundary[..<endRange.lowerBound]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if boundary.hasPrefix("\"") && boundary.hasSuffix("\"") {
|
|
102
|
+
return String(boundary.dropFirst().dropLast())
|
|
103
|
+
} else {
|
|
104
|
+
return String(boundary)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return nil
|
|
109
|
+
}
|
|
89
110
|
|
|
90
111
|
public func getRequestDataAsString(_ data: JSValue) throws -> Data {
|
|
91
112
|
guard let stringData = data as? String else {
|
|
@@ -110,7 +131,7 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
|
|
|
110
131
|
}
|
|
111
132
|
var data = Data()
|
|
112
133
|
var boundary = UUID().uuidString
|
|
113
|
-
if contentType.contains("="), let contentBoundary =
|
|
134
|
+
if contentType.contains("boundary="), let contentBoundary = extractBoundary(from: contentType) {
|
|
114
135
|
boundary = contentBoundary
|
|
115
136
|
} else {
|
|
116
137
|
overrideContentType(boundary)
|
|
@@ -499,6 +499,10 @@ var nativeBridge = (function (exports) {
|
|
|
499
499
|
if (typeof resource === 'string') {
|
|
500
500
|
return await win.CapacitorWebFetch(createProxyUrl(resource, win), options);
|
|
501
501
|
}
|
|
502
|
+
else if (resource instanceof URL) {
|
|
503
|
+
const modifiedURL = new URL(createProxyUrl(resource.toString(), win));
|
|
504
|
+
return await win.CapacitorWebFetch(modifiedURL, options);
|
|
505
|
+
}
|
|
502
506
|
else if (resource instanceof Request) {
|
|
503
507
|
const modifiedRequest = new Request(createProxyUrl(resource.url, win), resource);
|
|
504
508
|
return await win.CapacitorWebFetch(modifiedRequest, options);
|
package/package.json
CHANGED