Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sitemapper

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitemapper - npm Package Compare versions

Comparing version 3.1.12 to 3.1.15

2

lib/assets/sitemapper.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xml2js=require("xml2js"),_got=_interopRequireDefault(require("got")),_zlib=_interopRequireDefault(require("zlib")),_url=_interopRequireDefault(require("url")),_path=_interopRequireDefault(require("path"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}class Sitemapper{constructor(a){var b=a||{requestHeaders:{}};this.url=b.url,this.timeout=b.timeout||15e3,this.timeoutTable={},this.requestHeaders=b.requestHeaders,this.debug=b.debug}fetch(){var a=arguments,b=this;return _asyncToGenerator(function*(){var c=0<a.length&&a[0]!==void 0?a[0]:b.url,d=[];try{d=yield b.crawl(c)}catch(a){b.debug&&console.error(a)}return{url:c,sites:d}})()}static get timeout(){return this.timeout}static set timeout(a){this.timeout=a}static set url(a){this.url=a}static get url(){return this.url}static set debug(a){this.debug=a}static get debug(){return this.debug}parse(){var a=arguments,b=this;return _asyncToGenerator(function*(){var c=0<a.length&&a[0]!==void 0?a[0]:b.url,d={method:"GET",resolveWithFullResponse:!0,gzip:!0,responseType:"buffer",headers:b.requestHeaders};try{var e=(0,_got.default)(c,d);b.initializeTimeout(c,e);var f=yield e;if(!f||200!==f.statusCode)return clearTimeout(b.timeoutTable[c]),{error:f.error,data:f};var g=b.isGzip(c)?yield b.inflateResponseBody(f.body):f.body;var h=yield(0,_xml2js.parseStringPromise)(g);return{error:null,data:h}}catch(a){return"CancelError"===a.name?{error:"Request timed out after ".concat(b.timeout," milliseconds for url: '").concat(c,"'"),data:a}:{error:a.error,data:a}}})()}initializeTimeout(a,b){this.timeoutTable[a]=setTimeout(()=>b.cancel(),this.timeout)}crawl(a){var b=this;return _asyncToGenerator(function*(){try{var{error:g,data:h}=yield b.parse(a);if(clearTimeout(b.timeoutTable[a]),g)return b.debug&&console.error("Error occurred during \"crawl('".concat(a,"')\":\n\r Error: ").concat(g)),[];if(h&&h.urlset&&h.urlset.url){b.debug&&console.debug("Urlset found during \"crawl('".concat(a,"')\""));var i=h.urlset.url.map(a=>a.loc&&a.loc[0]);return[].concat(i)}if(h&&h.sitemapindex){b.debug&&console.debug("Additional sitemap found during \"crawl('".concat(a,"')\""));var c=h.sitemapindex.sitemap.map(a=>a.loc&&a.loc[0]),d=c.map(a=>b.crawl(a)),e=yield Promise.all(d),f=e.filter(a=>!a.error).reduce((a,b)=>a.concat(b),[]);return f}return b.debug&&console.error("Unknown state during \"crawl('".concat(a,")'\":"),g,h),[]}catch(a){b.debug&&b.debug&&console.error(a)}})()}getSites(){var a=arguments,b=this;return _asyncToGenerator(function*(){var c=0<a.length&&a[0]!==void 0?a[0]:b.url,d=1<a.length?a[1]:void 0;console.warn("\r\nWarning:","function .getSites() is deprecated, please use the function .fetch()\r\n");var e={},f=[];try{var g=yield b.fetch(c);f=g.sites}catch(a){e=a}return d(e,f)})()}isGzip(a){var b=_url.default.parse(a),c=_path.default.extname(b.path);return".gz"===c}inflateResponseBody(a){return new Promise((b,c)=>{var d=Buffer.from(a,"utf8");_zlib.default.gunzip(d,function(a,d){a?c(a):b(d)})})}}exports.default=Sitemapper,module.exports=exports.default,module.exports.default=exports.default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xml2js=require("xml2js"),_got=_interopRequireDefault(require("got")),_zlib=_interopRequireDefault(require("zlib")),_url=_interopRequireDefault(require("url")),_path=_interopRequireDefault(require("path"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}class Sitemapper{constructor(a){var b=a||{requestHeaders:{}};this.url=b.url,this.timeout=b.timeout||15e3,this.timeoutTable={},this.requestHeaders=b.requestHeaders,this.debug=b.debug}fetch(){var a=arguments,b=this;return _asyncToGenerator(function*(){var c=0<a.length&&a[0]!==void 0?a[0]:b.url,d=[];try{d=yield b.crawl(c)}catch(a){b.debug&&console.error(a)}return{url:c,sites:d}})()}static get timeout(){return this.timeout}static set timeout(a){this.timeout=a}static set url(a){this.url=a}static get url(){return this.url}static set debug(a){this.debug=a}static get debug(){return this.debug}parse(){var a=arguments,b=this;return _asyncToGenerator(function*(){var c=0<a.length&&a[0]!==void 0?a[0]:b.url,d={method:"GET",resolveWithFullResponse:!0,gzip:!0,responseType:"buffer",headers:b.requestHeaders};try{var e=(0,_got.default)(c,d);b.initializeTimeout(c,e);var f=yield e;if(!f||200!==f.statusCode)return clearTimeout(b.timeoutTable[c]),{error:f.error,data:f};var g=b.isGzip(c)?yield b.decompressResponseBody(f.body):f.body;var h=yield(0,_xml2js.parseStringPromise)(g);return{error:null,data:h}}catch(a){return"CancelError"===a.name?{error:"Request timed out after ".concat(b.timeout," milliseconds for url: '").concat(c,"'"),data:a}:{error:a.error,data:a}}})()}initializeTimeout(a,b){this.timeoutTable[a]=setTimeout(()=>b.cancel(),this.timeout)}crawl(a){var b=this;return _asyncToGenerator(function*(){try{var{error:g,data:h}=yield b.parse(a);if(clearTimeout(b.timeoutTable[a]),g)return b.debug&&console.error("Error occurred during \"crawl('".concat(a,"')\":\n\r Error: ").concat(g)),[];if(h&&h.urlset&&h.urlset.url){b.debug&&console.debug("Urlset found during \"crawl('".concat(a,"')\""));var i=h.urlset.url.map(a=>a.loc&&a.loc[0]);return[].concat(i)}if(h&&h.sitemapindex){b.debug&&console.debug("Additional sitemap found during \"crawl('".concat(a,"')\""));var c=h.sitemapindex.sitemap.map(a=>a.loc&&a.loc[0]),d=c.map(a=>b.crawl(a)),e=yield Promise.all(d),f=e.filter(a=>!a.error).reduce((a,b)=>a.concat(b),[]);return f}return b.debug&&console.error("Unknown state during \"crawl('".concat(a,")'\":"),g,h),[]}catch(a){b.debug&&b.debug&&console.error(a)}})()}getSites(){var a=arguments,b=this;return _asyncToGenerator(function*(){var c=0<a.length&&a[0]!==void 0?a[0]:b.url,d=1<a.length?a[1]:void 0;console.warn("\r\nWarning:","function .getSites() is deprecated, please use the function .fetch()\r\n");var e={},f=[];try{var g=yield b.fetch(c);f=g.sites}catch(a){e=a}return d(e,f)})()}isGzip(a){var b=_url.default.parse(a),c=_path.default.extname(b.path);return".gz"===c}decompressResponseBody(a){return new Promise((b,c)=>{var d=Buffer.from(a);_zlib.default.gunzip(d,(a,d)=>{a?c(a):b(d)})})}}exports.default=Sitemapper,module.exports=exports.default,module.exports.default=exports.default;
//# sourceMappingURL=sitemapper.js.map
{
"name": "sitemapper",
"version": "3.1.12",
"version": "3.1.15",
"description": "Parser for XML Sitemaps to be used with Robots.txt and web crawlers",

@@ -5,0 +5,0 @@ "keywords": [

@@ -46,3 +46,3 @@ ## Sitemap-parser

console.log(sites);
catch (error) {
} catch (error) {
console.log(error);

@@ -49,0 +49,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc