@capacitor/ios
Advanced tools
Comparing version 6.0.0-rc.0 to 6.0.0-rc.1
@@ -114,9 +114,5 @@ | ||
const formData = await convertFormData(body); | ||
const boundary = `${Date.now()}`; | ||
return { | ||
data: formData, | ||
type: 'formData', | ||
headers: { | ||
'Content-Type': `multipart/form-data; boundary=--${boundary}`, | ||
}, | ||
}; | ||
@@ -134,2 +130,25 @@ } | ||
}; | ||
const CAPACITOR_HTTP_INTERCEPTOR = '/_capacitor_http_interceptor_'; | ||
const CAPACITOR_HTTPS_INTERCEPTOR = '/_capacitor_https_interceptor_'; | ||
// TODO: export as Cap function | ||
const isRelativeOrProxyUrl = (url) => !url || | ||
!(url.startsWith('http:') || url.startsWith('https:')) || | ||
url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1 || | ||
url.indexOf(CAPACITOR_HTTPS_INTERCEPTOR) > -1; | ||
// TODO: export as Cap function | ||
const createProxyUrl = (url, win) => { | ||
var _a, _b; | ||
if (isRelativeOrProxyUrl(url)) | ||
return url; | ||
const proxyUrl = new URL(url); | ||
const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : ''); | ||
const isHttps = proxyUrl.protocol === 'https:'; | ||
const originalHost = encodeURIComponent(proxyUrl.host); | ||
const originalPathname = proxyUrl.pathname; | ||
proxyUrl.protocol = bridgeUrl.protocol; | ||
proxyUrl.hostname = bridgeUrl.hostname; | ||
proxyUrl.port = bridgeUrl.port; | ||
proxyUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${originalHost}${originalPathname}`; | ||
return proxyUrl.toString(); | ||
}; | ||
const initBridge = (w) => { | ||
@@ -284,2 +303,6 @@ const getPlatformId = (win) => { | ||
}; | ||
IonicWebView.setServerAssetPath = (path) => { | ||
var _a; | ||
(_a = Plugins === null || Plugins === void 0 ? void 0 : Plugins.WebView) === null || _a === void 0 ? void 0 : _a.setServerAssetPath({ path }); | ||
}; | ||
IonicWebView.setServerBasePath = (path) => { | ||
@@ -478,2 +501,15 @@ var _a; | ||
} | ||
if (!(options === null || options === void 0 ? void 0 : options.method) || | ||
options.method.toLocaleUpperCase() === 'GET' || | ||
options.method.toLocaleUpperCase() === 'HEAD' || | ||
options.method.toLocaleUpperCase() === 'OPTIONS' || | ||
options.method.toLocaleUpperCase() === 'TRACE') { | ||
if (typeof resource === 'string') { | ||
return await win.CapacitorWebFetch(createProxyUrl(resource, win), options); | ||
} | ||
else if (resource instanceof Request) { | ||
const modifiedRequest = new Request(createProxyUrl(resource.url, win), resource); | ||
return await win.CapacitorWebFetch(modifiedRequest, options); | ||
} | ||
} | ||
const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`; | ||
@@ -548,3 +584,2 @@ console.time(tag); | ||
const prototype = win.CapacitorWebXMLHttpRequest.prototype; | ||
const isRelativeURL = (url) => !url || !(url.startsWith('http:') || url.startsWith('https:')); | ||
const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' && | ||
@@ -554,3 +589,3 @@ ProgressEvent.prototype instanceof Event; | ||
prototype.abort = function () { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.abort.call(this); | ||
@@ -566,6 +601,14 @@ } | ||
prototype.open = function (method, url) { | ||
this._method = method.toLocaleUpperCase(); | ||
this._url = url; | ||
this._method = method; | ||
if (isRelativeURL(url)) { | ||
return win.CapacitorWebXMLHttpRequest.open.call(this, method, url); | ||
if (!this._method || | ||
this._method === 'GET' || | ||
this._method === 'HEAD' || | ||
this._method === 'OPTIONS' || | ||
this._method === 'TRACE') { | ||
if (isRelativeOrProxyUrl(url)) { | ||
return win.CapacitorWebXMLHttpRequest.open.call(this, method, url); | ||
} | ||
this._url = createProxyUrl(this._url, win); | ||
return win.CapacitorWebXMLHttpRequest.open.call(this, method, this._url); | ||
} | ||
@@ -579,3 +622,3 @@ setTimeout(() => { | ||
prototype.setRequestHeader = function (header, value) { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.setRequestHeader.call(this, header, value); | ||
@@ -587,3 +630,3 @@ } | ||
prototype.send = function (body) { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.send.call(this, body); | ||
@@ -650,3 +693,4 @@ } | ||
} | ||
this.responseText = ((_a = nativeResponse.headers['Content-Type']) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) | ||
this.responseText = ((_a = (nativeResponse.headers['Content-Type'] || | ||
nativeResponse.headers['content-type'])) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) | ||
? JSON.stringify(nativeResponse.data) | ||
@@ -708,3 +752,3 @@ : nativeResponse.data; | ||
prototype.getAllResponseHeaders = function () { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.getAllResponseHeaders.call(this); | ||
@@ -722,3 +766,3 @@ } | ||
prototype.getResponseHeader = function (name) { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.getResponseHeader.call(this, name); | ||
@@ -725,0 +769,0 @@ } |
{ | ||
"name": "@capacitor/ios", | ||
"version": "6.0.0-rc.0", | ||
"version": "6.0.0-rc.1", | ||
"description": "Capacitor: Cross-platform apps with JavaScript and the web", | ||
@@ -23,3 +23,3 @@ "homepage": "https://capacitorjs.com", | ||
"scripts": { | ||
"verify": "npm run xc:build:Capacitor && npm run xc:build:CapacitorCordova && pod lib lint --allow-warnings Capacitor.podspec && pod lib lint --allow-warnings CapacitorCordova.podspec", | ||
"verify": "npm run xc:build:Capacitor && npm run xc:build:CapacitorCordova", | ||
"xc:build:Capacitor": "cd Capacitor && xcodebuild -workspace Capacitor.xcworkspace -scheme Capacitor && cd ..", | ||
@@ -30,3 +30,3 @@ "xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd ..", | ||
"peerDependencies": { | ||
"@capacitor/core": "^6.0.0-rc.0" | ||
"@capacitor/core": "^6.0.0-rc.1" | ||
}, | ||
@@ -33,0 +33,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
375416
104
1010
271