mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-01-31 00:00:03 +08:00
chore: add JS linter
This commit is contained in:
6
.eslintignore
Normal file
6
.eslintignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
temp
|
||||||
|
platforms
|
||||||
|
**/*.min.js
|
||||||
|
www/umd-tough-cookie.js
|
||||||
|
www/lodash.js
|
||||||
25
.eslintrc.json
Normal file
25
.eslintrc.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"es2020": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2020,
|
||||||
|
"sourceType": "script"
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"test/**/*.js",
|
||||||
|
"www/**/*.js"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"mocha": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@@ -17,6 +17,21 @@ env:
|
|||||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Install node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.node_version }}
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: package-lock.json
|
||||||
|
- name: Install node modules
|
||||||
|
run: npm ci
|
||||||
|
- name: Run ESLint
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
test-www-interface:
|
test-www-interface:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
1125
package-lock.json
generated
1125
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
|||||||
"build:browser": "./scripts/build-test-app.sh --browser",
|
"build:browser": "./scripts/build-test-app.sh --browser",
|
||||||
"build:android": "./scripts/build-test-app.sh --android --emulator",
|
"build:android": "./scripts/build-test-app.sh --android --emulator",
|
||||||
"build:ios": "./scripts/build-test-app.sh --ios --emulator",
|
"build:ios": "./scripts/build-test-app.sh --ios --emulator",
|
||||||
|
"lint": "eslint . --ext .js",
|
||||||
"test:android": "npm run update:cert && npm run build:android && ./scripts/test-app.sh --android --emulator",
|
"test:android": "npm run update:cert && npm run build:android && ./scripts/test-app.sh --android --emulator",
|
||||||
"test:ios": "npm run update:cert && npm run build:ios && ./scripts/test-app.sh --ios --emulator",
|
"test:ios": "npm run update:cert && npm run build:ios && ./scripts/test-app.sh --ios --emulator",
|
||||||
"test:app": "npm run test:android && npm run test:ios",
|
"test:app": "npm run test:android && npm run test:ios",
|
||||||
@@ -61,6 +62,7 @@
|
|||||||
"chai": "4.3.6",
|
"chai": "4.3.6",
|
||||||
"colors": "1.4.0",
|
"colors": "1.4.0",
|
||||||
"cordova": "11.0.0",
|
"cordova": "11.0.0",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
"mocha": "9.2.2",
|
"mocha": "9.2.2",
|
||||||
"umd-tough-cookie": "3.0.0",
|
"umd-tough-cookie": "3.0.0",
|
||||||
"wd": "1.14.0",
|
"wd": "1.14.0",
|
||||||
|
|||||||
27
src/browser/cordova-http-plugin.js
vendored
27
src/browser/cordova-http-plugin.js
vendored
@@ -193,7 +193,7 @@ function sendRequest(method, withData, opts, success, failure) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (serializer) {
|
switch (serializer) {
|
||||||
case 'json':
|
case 'json': {
|
||||||
setDefaultContentType(headers, 'application/json; charset=utf8');
|
setDefaultContentType(headers, 'application/json; charset=utf8');
|
||||||
processedData = serializeJsonData(data);
|
processedData = serializeJsonData(data);
|
||||||
|
|
||||||
@@ -202,18 +202,21 @@ function sendRequest(method, withData, opts, success, failure) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'utf8':
|
case 'utf8': {
|
||||||
setDefaultContentType(headers, 'text/plain; charset=utf8');
|
setDefaultContentType(headers, 'text/plain; charset=utf8');
|
||||||
processedData = data.text;
|
processedData = data.text;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'urlencoded':
|
case 'urlencoded': {
|
||||||
setDefaultContentType(headers, 'application/x-www-form-urlencoded');
|
setDefaultContentType(headers, 'application/x-www-form-urlencoded');
|
||||||
processedData = serializeParams(data);
|
processedData = serializeParams(data);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'multipart':
|
case 'multipart': {
|
||||||
const contentType = getHeaderValue(headers, 'Content-Type');
|
const contentType = getHeaderValue(headers, 'Content-Type');
|
||||||
|
|
||||||
// intentionally don't set a default content type
|
// intentionally don't set a default content type
|
||||||
@@ -224,11 +227,13 @@ function sendRequest(method, withData, opts, success, failure) {
|
|||||||
|
|
||||||
processedData = processMultipartData(data);
|
processedData = processMultipartData(data);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'raw':
|
case 'raw': {
|
||||||
setDefaultContentType(headers, 'application/octet-stream');
|
setDefaultContentType(headers, 'application/octet-stream');
|
||||||
processedData = data;
|
processedData = data;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// requesting text instead of JSON because it's parsed in the response handler
|
// requesting text instead of JSON because it's parsed in the response handler
|
||||||
@@ -283,7 +288,7 @@ function sendRequest(method, withData, opts, success, failure) {
|
|||||||
xhr.send(processedData);
|
xhr.send(processedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function abort(opts, success, failure) {
|
function abort(opts, success) {
|
||||||
var reqId = opts[0];
|
var reqId = opts[0];
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
||||||
@@ -318,19 +323,19 @@ var browserInterface = {
|
|||||||
abort: function (success, failure, opts) {
|
abort: function (success, failure, opts) {
|
||||||
return abort(opts, success, failure);
|
return abort(opts, success, failure);
|
||||||
},
|
},
|
||||||
uploadFile: function (success, failure, opts) {
|
uploadFile: function (success, failure) {
|
||||||
return failure('advanced-http: function "uploadFile" not supported on browser platform');
|
return failure('advanced-http: function "uploadFile" not supported on browser platform');
|
||||||
},
|
},
|
||||||
uploadFiles: function (success, failure, opts) {
|
uploadFiles: function (success, failure) {
|
||||||
return failure('advanced-http: function "uploadFiles" not supported on browser platform');
|
return failure('advanced-http: function "uploadFiles" not supported on browser platform');
|
||||||
},
|
},
|
||||||
downloadFile: function (success, failure, opts) {
|
downloadFile: function (success, failure) {
|
||||||
return failure('advanced-http: function "downloadFile" not supported on browser platform');
|
return failure('advanced-http: function "downloadFile" not supported on browser platform');
|
||||||
},
|
},
|
||||||
setServerTrustMode: function (success, failure, opts) {
|
setServerTrustMode: function (success, failure) {
|
||||||
return failure('advanced-http: function "setServerTrustMode" not supported on browser platform');
|
return failure('advanced-http: function "setServerTrustMode" not supported on browser platform');
|
||||||
},
|
},
|
||||||
setClientAuthMode: function (success, failure, opts) {
|
setClientAuthMode: function (success, failure) {
|
||||||
return failure('advanced-http: function "setClientAuthMode" not supported on browser platform');
|
return failure('advanced-http: function "setClientAuthMode" not supported on browser platform');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* global hooks, tests */
|
||||||
|
|
||||||
const app = {
|
const app = {
|
||||||
testIndex: -1,
|
testIndex: -1,
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* global cordova, resolveLocalFileSystemURL, should */
|
||||||
|
|
||||||
const hooks = {
|
const hooks = {
|
||||||
onBeforeEachTest: function (resolve, reject) {
|
onBeforeEachTest: function (resolve, reject) {
|
||||||
cordova.plugin.http.clearCookies();
|
cordova.plugin.http.clearCookies();
|
||||||
@@ -92,12 +94,12 @@ const helpers = {
|
|||||||
// abort is not working reliably; will be documented in known issues
|
// abort is not working reliably; will be documented in known issues
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (window.cordova && window.cordova.platformId === 'android') {
|
// if (window.cordova && window.cordova.platformId === 'android') {
|
||||||
var version = device.version; // NOTE will throw error if cordova is present without cordova-plugin-device
|
// var version = device.version; // NOTE will throw error if cordova is present without cordova-plugin-device
|
||||||
var major = parseInt(/^(\d+)(\.|$)/.exec(version)[1], 10);
|
// var major = parseInt(/^(\d+)(\.|$)/.exec(version)[1], 10);
|
||||||
return isFinite(major) && major >= 6;
|
// return isFinite(major) && major >= 6;
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
},
|
},
|
||||||
getAbortDelay: function () { return 0; },
|
getAbortDelay: function () { return 0; },
|
||||||
getDemoArrayBuffer: function(size) {
|
getDemoArrayBuffer: function(size) {
|
||||||
@@ -229,7 +231,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send JSON object correctly (POST)',
|
description: 'should send JSON object correctly (POST)',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"json\\":\\"test\\": \\"testString\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"json\\":\\"test\\": \\"testString\\"}" ...',
|
||||||
before: helpers.setJsonSerializer,
|
before: helpers.setJsonSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -239,7 +241,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send JSON object correctly (PUT)',
|
description: 'should send JSON object correctly (PUT)',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"json\\":\\"test\\": \\"testString\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"json\\":\\"test\\": \\"testString\\"}" ...',
|
||||||
before: helpers.setJsonSerializer,
|
before: helpers.setJsonSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.put('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.put('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -249,7 +251,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send JSON object correctly (PATCH)',
|
description: 'should send JSON object correctly (PATCH)',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"json\\":\\"test\\": \\"testString\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"json\\":\\"test\\": \\"testString\\"}" ...',
|
||||||
before: helpers.setJsonSerializer,
|
before: helpers.setJsonSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.patch('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.patch('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -259,7 +261,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send JSON array correctly (POST) #26',
|
description: 'should send JSON array correctly (POST) #26',
|
||||||
expected: 'resolved: {"status": 200, "data": "[ 1, 2, 3 ]\" ...',
|
expected: 'resolved: {"status": 200, "data": "[ 1, 2, 3 ]" ...',
|
||||||
before: helpers.setJsonSerializer,
|
before: helpers.setJsonSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', [1, 2, 3], {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', [1, 2, 3], {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -269,7 +271,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send JSON array correctly (PUT) #26',
|
description: 'should send JSON array correctly (PUT) #26',
|
||||||
expected: 'resolved: {"status": 200, "data": "[ 1, 2, 3 ]\" ...',
|
expected: 'resolved: {"status": 200, "data": "[ 1, 2, 3 ]" ...',
|
||||||
before: helpers.setJsonSerializer,
|
before: helpers.setJsonSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.put('http://httpbin.org/anything', [1, 2, 3], {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.put('http://httpbin.org/anything', [1, 2, 3], {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -279,7 +281,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send JSON array correctly (PATCH) #26',
|
description: 'should send JSON array correctly (PATCH) #26',
|
||||||
expected: 'resolved: {"status": 200, "data": "[ 1, 2, 3 ]\" ...',
|
expected: 'resolved: {"status": 200, "data": "[ 1, 2, 3 ]" ...',
|
||||||
before: helpers.setJsonSerializer,
|
before: helpers.setJsonSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.patch('http://httpbin.org/anything', [1, 2, 3], {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.patch('http://httpbin.org/anything', [1, 2, 3], {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -290,7 +292,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send url encoded data correctly (POST) #41',
|
description: 'should send url encoded data correctly (POST) #41',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"form\\":\\"test\\": \\"testString\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"form\\":\\"test\\": \\"testString\\"}" ...',
|
||||||
before: helpers.setUrlEncodedSerializer,
|
before: helpers.setUrlEncodedSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -300,7 +302,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send url encoded data correctly (PUT)',
|
description: 'should send url encoded data correctly (PUT)',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"form\\":\\"test\\": \\"testString\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"form\\":\\"test\\": \\"testString\\"}" ...',
|
||||||
before: helpers.setUrlEncodedSerializer,
|
before: helpers.setUrlEncodedSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.put('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.put('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -310,7 +312,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should send url encoded data correctly (PATCH)',
|
description: 'should send url encoded data correctly (PATCH)',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"form\\":\\"test\\": \\"testString\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"form\\":\\"test\\": \\"testString\\"}" ...',
|
||||||
before: helpers.setUrlEncodedSerializer,
|
before: helpers.setUrlEncodedSerializer,
|
||||||
func: function (resolve, reject) { cordova.plugin.http.patch('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.patch('http://httpbin.org/anything', { test: 'testString' }, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
@@ -330,7 +332,10 @@ const tests = [
|
|||||||
{
|
{
|
||||||
description: 'should not follow 302 redirect when following redirects is disabled',
|
description: 'should not follow 302 redirect when following redirects is disabled',
|
||||||
expected: 'rejected: {"status": 302, ...',
|
expected: 'rejected: {"status": 302, ...',
|
||||||
before: function (resolve, reject) { cordova.plugin.http.setFollowRedirect(false); resolve(); },
|
before: function (resolve) {
|
||||||
|
cordova.plugin.http.setFollowRedirect(false);
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
func: function (resolve, reject) { cordova.plugin.http.get('http://httpbingo.org/redirect-to?url=http://httpbingo.org/anything', {}, {}, resolve, reject); },
|
func: function (resolve, reject) { cordova.plugin.http.get('http://httpbingo.org/redirect-to?url=http://httpbingo.org/anything', {}, {}, resolve, reject); },
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
result.type.should.be.equal('rejected');
|
result.type.should.be.equal('rejected');
|
||||||
@@ -427,7 +432,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should encode HTTP array params correctly (GET) #45',
|
description: 'should encode HTTP array params correctly (GET) #45',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\\"url\\":\\"http://httpbin.org/get?myArray[]=val1&myArray[]=val2&myArray[]=val3\\"}\" ...',
|
expected: 'resolved: {"status": 200, "data": "{\\"url\\":\\"http://httpbin.org/get?myArray[]=val1&myArray[]=val2&myArray[]=val3\\"}" ...',
|
||||||
func: function (resolve, reject) {
|
func: function (resolve, reject) {
|
||||||
cordova.plugin.http.get('http://httpbin.org/get', { myArray: ['val1', 'val2', 'val3'], myString: 'testString' }, {}, resolve, reject);
|
cordova.plugin.http.get('http://httpbin.org/get', { myArray: ['val1', 'val2', 'val3'], myString: 'testString' }, {}, resolve, reject);
|
||||||
},
|
},
|
||||||
@@ -455,8 +460,9 @@ const tests = [
|
|||||||
{
|
{
|
||||||
description: 'should throw an error while setting non-string value as global header #54',
|
description: 'should throw an error while setting non-string value as global header #54',
|
||||||
expected: 'throwed: "advanced-http: header values must be strings"',
|
expected: 'throwed: "advanced-http: header values must be strings"',
|
||||||
func: function (resolve, reject) {
|
func: function (resolve) {
|
||||||
cordova.plugin.http.setHeader('myTestHeader', 2);
|
cordova.plugin.http.setHeader('myTestHeader', 2);
|
||||||
|
resolve();
|
||||||
},
|
},
|
||||||
validationFunc: function (driver, result) {
|
validationFunc: function (driver, result) {
|
||||||
result.type.should.be.equal('throwed');
|
result.type.should.be.equal('throwed');
|
||||||
@@ -495,7 +501,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should not send programmatically set cookies after running "clearCookies" (GET) #59',
|
description: 'should not send programmatically set cookies after running "clearCookies" (GET) #59',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\"headers\": {\"Cookie\": \"\"...',
|
expected: 'resolved: {"status": 200, "data": "{"headers": {"Cookie": ""...',
|
||||||
func: function (resolve, reject) {
|
func: function (resolve, reject) {
|
||||||
cordova.plugin.http.setCookie('http://httpbin.org/get', 'myCookie=myValue');
|
cordova.plugin.http.setCookie('http://httpbin.org/get', 'myCookie=myValue');
|
||||||
cordova.plugin.http.setCookie('http://httpbin.org/get', 'mySecondCookie=mySecondValue');
|
cordova.plugin.http.setCookie('http://httpbin.org/get', 'mySecondCookie=mySecondValue');
|
||||||
@@ -1011,7 +1017,7 @@ const tests = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: 'should not send any cookies after running "clearCookies" (GET) #248',
|
description: 'should not send any cookies after running "clearCookies" (GET) #248',
|
||||||
expected: 'resolved: {"status": 200, "data": "{\"cookies\":{}} ...',
|
expected: 'resolved: {"status": 200, "data": "{"cookies":{}} ...',
|
||||||
before: helpers.disableFollowingRedirect,
|
before: helpers.disableFollowingRedirect,
|
||||||
func: function (resolve, reject) {
|
func: function (resolve, reject) {
|
||||||
cordova.plugin.http.get('https://httpbin.org/cookies/set?myCookieKey=myCookieValue', {}, {}, function () {
|
cordova.plugin.http.get('https://httpbin.org/cookies/set?myCookieKey=myCookieValue', {}, {}, function () {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function getCaps(environment, os, runtime) {
|
|||||||
caps.name = `cordova-plugin-advanced-http (${os})`;
|
caps.name = `cordova-plugin-advanced-http (${os})`;
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
};
|
}
|
||||||
|
|
||||||
function capitalize(text) {
|
function capitalize(text) {
|
||||||
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ async function validateTestIndex(driver, testIndex) {
|
|||||||
|
|
||||||
async function validateTestTitle(driver, testTitle) {
|
async function validateTestTitle(driver, testTitle) {
|
||||||
const description = await driver.elementById('descriptionLbl').text();
|
const description = await driver.elementById('descriptionLbl').text();
|
||||||
const title = description.match(/\d+:\ (.*)/)[1];
|
const title = description.match(/\d+: (.*)/)[1];
|
||||||
|
|
||||||
title.should.be.equal(testTitle, 'Test description is not matching!');
|
title.should.be.equal(testTitle, 'Test description is not matching!');
|
||||||
}
|
}
|
||||||
@@ -106,6 +106,7 @@ async function validateTestTitle(driver, testTitle) {
|
|||||||
async function waitToBeFinished(driver, timeout) {
|
async function waitToBeFinished(driver, timeout) {
|
||||||
const timeoutTimestamp = Date.now() + timeout;
|
const timeoutTimestamp = Date.now() + timeout;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
if (await driver.elementById('statusInput').getValue() === 'finished') {
|
if (await driver.elementById('statusInput').getValue() === 'finished') {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const BlobMock = require('./Blob.mock');
|
|||||||
module.exports = class FileMock extends BlobMock {
|
module.exports = class FileMock extends BlobMock {
|
||||||
constructor(blob, fileName) {
|
constructor(blob, fileName) {
|
||||||
super(blob, { type: blob.type });
|
super(blob, { type: blob.type });
|
||||||
this._fileName = fileName !== undefined ? fileName : 'blob';
|
this._fileName = fileName !== undefined ? fileName : 'blob';
|
||||||
this.__lastModifiedDate = new Date();
|
this.__lastModifiedDate = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* global FileSystem */
|
||||||
|
|
||||||
module.exports = function init(global, jsUtil, cookieHandler, messages, base64, errorCodes, dependencyValidator, ponyfills) {
|
module.exports = function init(global, jsUtil, cookieHandler, messages, base64, errorCodes, dependencyValidator, ponyfills) {
|
||||||
var validSerializers = ['urlencoded', 'json', 'utf8', 'raw', 'multipart'];
|
var validSerializers = ['urlencoded', 'json', 'utf8', 'raw', 'multipart'];
|
||||||
var validCertModes = ['default', 'nocheck', 'pinned', 'legacy'];
|
var validCertModes = ['default', 'nocheck', 'pinned', 'legacy'];
|
||||||
@@ -66,7 +68,7 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64,
|
|||||||
for (var i = 0; i < globalKeys.length; i++) {
|
for (var i = 0; i < globalKeys.length; i++) {
|
||||||
key = globalKeys[i];
|
key = globalKeys[i];
|
||||||
|
|
||||||
if (!localHeaders.hasOwnProperty(key)) {
|
if (!Object.prototype.hasOwnProperty.call(localHeaders, key)) {
|
||||||
localHeaders[key] = globalHeaders[key];
|
localHeaders[key] = globalHeaders[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,7 +363,7 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMatchingHostHeaders(url, headersList) {
|
function getMatchingHostHeaders(url, headersList) {
|
||||||
var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
|
var matches = url.match(/^https?:\/\/([^/?#]+)(?:[/?#]|$)/i);
|
||||||
var domain = matches && matches[1];
|
var domain = matches && matches[1];
|
||||||
|
|
||||||
return headersList[domain] || null;
|
return headersList[domain] || null;
|
||||||
|
|||||||
@@ -164,13 +164,15 @@ module.exports = function init(ToughCookie, _) {
|
|||||||
WebStorageCookieStore.prototype._readStore = function () {
|
WebStorageCookieStore.prototype._readStore = function () {
|
||||||
var json = this._storage.getItem(this._storeKey);
|
var json = this._storage.getItem(this._storeKey);
|
||||||
|
|
||||||
if (json !== null) {
|
if (json === null) {
|
||||||
try {
|
return {};
|
||||||
return JSON.parse(json);
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
try {
|
||||||
|
return JSON.parse(json);
|
||||||
|
} catch (e) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WebStorageCookieStore.prototype._writeStore = function (store) {
|
WebStorageCookieStore.prototype._writeStore = function (store) {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ module.exports = function init(exec, cookieHandler, urlUtil, helpers, globalConf
|
|||||||
|
|
||||||
function post(url, data, headers, success, failure) {
|
function post(url, data, headers, success, failure) {
|
||||||
return publicInterface.sendRequest(url, { method: 'post', data: data, headers: headers }, success, failure);
|
return publicInterface.sendRequest(url, { method: 'post', data: data, headers: headers }, success, failure);
|
||||||
};
|
}
|
||||||
|
|
||||||
function put(url, data, headers, success, failure) {
|
function put(url, data, headers, success, failure) {
|
||||||
return publicInterface.sendRequest(url, { method: 'put', data: data, headers: headers }, success, failure);
|
return publicInterface.sendRequest(url, { method: 'put', data: data, headers: headers }, success, failure);
|
||||||
@@ -209,7 +209,7 @@ module.exports = function init(exec, cookieHandler, urlUtil, helpers, globalConf
|
|||||||
|
|
||||||
function get(url, params, headers, success, failure) {
|
function get(url, params, headers, success, failure) {
|
||||||
return publicInterface.sendRequest(url, { method: 'get', params: params, headers: headers }, success, failure);
|
return publicInterface.sendRequest(url, { method: 'get', params: params, headers: headers }, success, failure);
|
||||||
};
|
}
|
||||||
|
|
||||||
function del(url, params, headers, success, failure) {
|
function del(url, params, headers, success, failure) {
|
||||||
return publicInterface.sendRequest(url, { method: 'delete', params: params, headers: headers }, success, failure);
|
return publicInterface.sendRequest(url, { method: 'delete', params: params, headers: headers }, success, failure);
|
||||||
@@ -221,7 +221,7 @@ module.exports = function init(exec, cookieHandler, urlUtil, helpers, globalConf
|
|||||||
|
|
||||||
function options(url, params, headers, success, failure) {
|
function options(url, params, headers, success, failure) {
|
||||||
return publicInterface.sendRequest(url, { method: 'options', params: params, headers: headers }, success, failure);
|
return publicInterface.sendRequest(url, { method: 'options', params: params, headers: headers }, success, failure);
|
||||||
};
|
}
|
||||||
|
|
||||||
function uploadFile(url, params, headers, filePath, name, success, failure) {
|
function uploadFile(url, params, headers, filePath, name, success, failure) {
|
||||||
return publicInterface.sendRequest(url, { method: 'upload', params: params, headers: headers, filePath: filePath, name: name }, success, failure);
|
return publicInterface.sendRequest(url, { method: 'upload', params: params, headers: headers, filePath: filePath, name: name }, success, failure);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ module.exports = function init(jsUtil) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseUrl(url) {
|
function parseUrl(url) {
|
||||||
var match = url.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
var match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
||||||
|
|
||||||
return match && {
|
return match && {
|
||||||
protocol: match[1],
|
protocol: match[1],
|
||||||
@@ -42,7 +42,7 @@ module.exports = function init(jsUtil) {
|
|||||||
var parts = [];
|
var parts = [];
|
||||||
|
|
||||||
for (var key in object) {
|
for (var key in object) {
|
||||||
if (!object.hasOwnProperty(key)) {
|
if (!Object.prototype.hasOwnProperty.call(object, key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user