Comparing version 6.0.2 to 6.0.3
@@ -10,3 +10,3 @@ 'use strict'; | ||
const isutf8 = require('isutf8'); | ||
const request = require('request'); | ||
const fetch = require('node-fetch'); | ||
const pth = require('path'); | ||
@@ -233,27 +233,23 @@ const MarkdownIt = require('markdown-it'); | ||
request.get({ | ||
method: 'GET', | ||
uri: url, | ||
gzip: true | ||
}, | ||
function(error, response, text) { | ||
if (error) { | ||
fetch(url) | ||
.then(response => { | ||
if (response.ok) { | ||
return response.text(); | ||
} else { | ||
throw Error(url + ': returns status code is ' + response.statusCode); | ||
} | ||
}) | ||
.then(text => { | ||
const startTime = Date.now(); | ||
checkText(text, function(err, data, originalText) { | ||
callback( | ||
err, | ||
err ? data : {resource: url, data: data, time: Date.now() - startTime}, | ||
originalText | ||
); | ||
}, settings); | ||
}) | ||
.catch(error => { | ||
callback(true, error); | ||
return; | ||
} | ||
if (response.statusCode !== 200) { | ||
callback(true, Error(url + ': returns status code is ' + response.statusCode)); | ||
return; | ||
} | ||
const startTime = Date.now(); | ||
checkText(text, function(err, data, originalText) { | ||
callback( | ||
err, | ||
err ? data : {resource: url, data: data, time: Date.now() - startTime}, | ||
originalText | ||
); | ||
}, settings); | ||
}); | ||
}); | ||
} | ||
@@ -276,52 +272,46 @@ | ||
request.get(url, function(error, response, xml) { | ||
let obj; | ||
if (error) { | ||
obj = [true, error]; | ||
results.push(obj); | ||
callback && callback.apply(this, obj); | ||
commonCallback(results); | ||
return; | ||
} | ||
if (response.statusCode !== 200) { | ||
obj = [true, Error(url + ': returns status code is ' + response.statusCode)]; | ||
results.push(obj); | ||
callback && callback.apply(this, obj); | ||
commonCallback(results); | ||
return; | ||
} | ||
const parser = new xml2js.Parser(); | ||
parser.parseString(xml, function(err, result) { | ||
if (err) { | ||
let obj = [true, Error(url + ': error parsing xml')]; | ||
results.push(obj); | ||
callback && callback.apply(this, obj); | ||
commonCallback(results); | ||
return; | ||
fetch(url) | ||
.then(res => { | ||
if (res.ok) { | ||
return res.text(); | ||
} else { | ||
throw Error(url + ': returns status code is ' + res.statusCode); | ||
} | ||
}) | ||
.then(xml => { | ||
const parser = new xml2js.Parser(); | ||
parser.parseString(xml, function(err, result) { | ||
if (err) { | ||
let obj = [true, Error(url + ': error parsing xml')]; | ||
results.push(obj); | ||
callback && callback.apply(this, obj); | ||
commonCallback(results); | ||
return; | ||
} | ||
const tasks = []; | ||
if (result && result.urlset && Array.isArray(result.urlset.url)) { | ||
result.urlset.url.forEach(function(el) { | ||
el.loc && el.loc.forEach(function(url) { | ||
tasks.push(function(cb) { | ||
checkUrl(url, function(err, data, originalText) { | ||
callback && callback(err, data, originalText); | ||
cb(null, [err, data]); | ||
}, settings); | ||
const tasks = []; | ||
if (result && result.urlset && Array.isArray(result.urlset.url)) { | ||
result.urlset.url.forEach(function(el) { | ||
el.loc && el.loc.forEach(function(url) { | ||
tasks.push(function(cb) { | ||
checkUrl(url, function(err, data, originalText) { | ||
callback && callback(err, data, originalText); | ||
cb(null, [err, data]); | ||
}, settings); | ||
}); | ||
}); | ||
}); | ||
} | ||
async.parallelLimit(tasks, getMaxRequest(settings), function(err, data) { | ||
commonCallback(data); | ||
}); | ||
} | ||
async.parallelLimit(tasks, getMaxRequest(settings), function(err, data) { | ||
commonCallback(data); | ||
}); | ||
}) | ||
.catch((error) => { | ||
const obj = [true, error]; | ||
results.push(obj); | ||
callback && callback.apply(this, obj); | ||
commonCallback(results); | ||
}); | ||
}); | ||
} | ||
@@ -328,0 +318,0 @@ |
@@ -13,3 +13,3 @@ { | ||
"description": "Search tool typos in the text, files and websites", | ||
"version": "6.0.2", | ||
"version": "6.0.3", | ||
"license": "MIT", | ||
@@ -36,3 +36,3 @@ "homepage": "https://github.com/hcodes/yaspeller", | ||
"dependencies": { | ||
"async": "^3.1.0", | ||
"async": "^3.2.0", | ||
"chalk": "^2.4.2", | ||
@@ -43,10 +43,10 @@ "commander": "^3.0.0", | ||
"escape-html": "^1.0.3", | ||
"eyo-kernel": "^2.5.1", | ||
"glob": "^7.1.3", | ||
"isutf8": "^2.0.3", | ||
"eyo-kernel": "^2.5.6", | ||
"glob": "^7.1.6", | ||
"isutf8": "^2.1.0", | ||
"markdown-it": "^10.0.0", | ||
"minimatch": "^3.0.4", | ||
"request": "^2.88.0", | ||
"strip-json-comments": "^3.0.0", | ||
"xml2js": "^0.4.19", | ||
"node-fetch": "^2.6.0", | ||
"strip-json-comments": "^3.0.1", | ||
"xml2js": "^0.4.23", | ||
"yandex-speller": "^4.0.0" | ||
@@ -56,7 +56,7 @@ }, | ||
"chai": "^4.2.0", | ||
"eslint": "^6.0.1", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.0", | ||
"eslint": "^6.8.0", | ||
"mocha": "^7.0.1", | ||
"nyc": "^14.1.1", | ||
"parse-json": "^5.0.0", | ||
"sinon": "^7.3.2" | ||
"sinon": "^9.0.0" | ||
}, | ||
@@ -71,3 +71,3 @@ "engines": { | ||
"unit-test": "mocha", | ||
"unit-test-coverage": "nyc mocha" | ||
"unit-test-coverage": "nyc --reporter=lcov --reporter=text-summary mocha" | ||
}, | ||
@@ -74,0 +74,0 @@ "files": [ |
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
Network access
Supply chain riskThis module accesses the network.
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
87967
2031
2
+ Addednode-fetch@^2.6.0
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedrequest@^2.88.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updatedasync@^3.2.0
Updatedeyo-kernel@^2.5.6
Updatedglob@^7.1.6
Updatedisutf8@^2.1.0
Updatedstrip-json-comments@^3.0.1
Updatedxml2js@^0.4.23