New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nuxtjs/sitemap

Package Overview
Dependencies
Maintainers
6
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/sitemap - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

12

CHANGELOG.md

@@ -5,2 +5,14 @@ # Changelog

## [2.2.0](https://github.com/nuxt-community/sitemap-module/compare/v2.1.0...v2.2.0) (2020-04-05)
### Features
* enable ETag header ([ccf3e10](https://github.com/nuxt-community/sitemap-module/commit/ccf3e10a44073c720eb651181db573bc17664a1c)), closes [#80](https://github.com/nuxt-community/sitemap-module/issues/80)
### Bug Fixes
* force route.url as string ([dc521ab](https://github.com/nuxt-community/sitemap-module/commit/dc521ab32456c511fec8b312c03544312ff2804d))
## [2.1.0](https://github.com/nuxt-community/sitemap-module/compare/v2.0.1...v2.1.0) (2020-03-27)

@@ -7,0 +19,0 @@

10

lib/builder.js

@@ -15,3 +15,3 @@ const { hostname } = require('os')

* @param {Array} routes
* @param {String} base
* @param {string} base
* @param {Request} req

@@ -41,3 +41,5 @@ * @returns {Sitemap} sitemap instance

routes = routes.map((route) => {
if (!route.url.endsWith('/')) route.url = `${route.url}/`
if (!route.url.endsWith('/')) {
route.url = `${route.url}/`
}
return route

@@ -62,3 +64,3 @@ })

...sitemapOptions,
url: join('.', sitemapOptions.url),
url: join('.', String(sitemapOptions.url)),
}

@@ -78,3 +80,3 @@ })

* @param {Object} options
* @param {String} base
* @param {string} base
* @param {Request} req

@@ -81,0 +83,0 @@ * @returns {string}

9

lib/cache.js

@@ -51,3 +51,3 @@ const { promisify } = require('util')

return new Promise((resolve, reject) => {
fn(function(err, routeParams) {
fn(function (err, routeParams) {
if (err) {

@@ -84,3 +84,3 @@ reject(err)

/**
* Make sure a route is an object with "url" property
* Make sure a route is an object with an "url" string property
*

@@ -91,5 +91,8 @@ * @param {Object | string} route Route Object or Payload Object or String value

function ensureIsValidRoute(route) {
return typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
route = typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
// force as string
route.url = String(route.url)
return route
}
module.exports = { createRoutesCache }
const { gzipSync } = require('zlib')
const generateETag = require('etag')
const fresh = require('fresh')
const { createSitemap, createSitemapIndex } = require('./builder')

@@ -69,2 +72,6 @@ const { createRoutesCache } = require('./cache')

const gzip = await createSitemap(options, routes, base, req).toGzip()
// Check cache headers
if (validHttpCache(gzip, options.etag, req, res)) {
return
}
// Send http response

@@ -94,2 +101,6 @@ res.setHeader('Content-Type', 'application/gzip')

const xml = await createSitemap(options, routes, base, req).toXML()
// Check cache headers
if (validHttpCache(xml, options.etag, req, res)) {
return
}
// Send http response

@@ -147,2 +158,28 @@ res.setHeader('Content-Type', 'application/xml')

/**
* Validate the freshness of HTTP cache using headers
*
* @param {Object} entity
* @param {Object} options
* @param {Request} req
* @param {Response} res
* @returns {boolean}
*/
function validHttpCache(entity, options, req, res) {
if (!options) {
return false
}
const { hash } = options
const etag = hash ? hash(entity, options) : generateETag(entity, options)
if (fresh(req.headers, { etag })) {
// Resource not modified
res.statusCode = 304
res.end()
return true
}
// Add ETag header
res.setHeader('ETag', etag)
return false
}
module.exports = { registerSitemaps, registerSitemap, registerSitemapIndex }

@@ -22,2 +22,3 @@ const logger = require('./logger')

cacheTime: 1000 * 60 * 15,
etag: nuxtInstance.options.render.etag,
filter: undefined,

@@ -24,0 +25,0 @@ gzip: false,

{
"name": "@nuxtjs/sitemap",
"version": "2.1.0",
"version": "2.2.0",
"description": "Automatically generate or serve dynamic sitemap.xml for Nuxt.js projects",

@@ -53,2 +53,4 @@ "keywords": [

"consola": "^2.11.3",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^8.1.0",

@@ -55,0 +57,0 @@ "is-https": "^1.0.0",

@@ -48,5 +48,7 @@ # Sitemap Module

```js
{
modules: [
'@nuxtjs/sitemap'
]
],
}
```

@@ -197,2 +199,12 @@

### `etag` (optional) - object
- Default: [`render.etag`](https://nuxtjs.org/api/configuration-render#etag) value from your `nuxt.config.js`
Enable the etag cache header on sitemap (See [etag](https://nuxtjs.org/api/configuration-render#etag) docs for possible options).
To disable etag for sitemap set `etag: false`
This option is enable only for the nuxt "universal" mode.
### `exclude` (optional) - string array

@@ -290,4 +302,3 @@

priority: 1,
lastmod: new Date(),
lastmodrealtime: true
lastmod: new Date()
}

@@ -298,3 +309,3 @@ }

See available options: https://github.com/ekalinin/sitemap.js#usage
See available options: https://github.com/ekalinin/sitemap.js/blob/4.1.1/README.md#sitemap-item-options

@@ -409,7 +420,3 @@ ## Sitemap Index Options

sitemap: {
routes: [
'/users/1',
'/users/2',
'/users/3'
]
routes: ['/users/1', '/users/2', '/users/3']
}

@@ -430,3 +437,3 @@ }

const { data } = await axios.get('https://jsonplaceholder.typicode.com/users')
return data.map(user => `/users/${user.username}`)
return data.map((user) => `/users/${user.username}`)
}

@@ -433,0 +440,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