@capacitor/ios 7.6.1 → 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.
|
@@ -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)
|
package/package.json
CHANGED