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

expired

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expired - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/expired.js

6

package.json
{
"name": "expired",
"version": "0.0.1",
"version": "0.1.0",
"description": "Calculate when HTTP cache headers expire",

@@ -8,3 +8,3 @@ "main": "src/index.js",

"test": "nyc ava",
"lint": "snazzy",
"lint": "xo",
"coverage": "nyc report --reporter=text-lcov | coveralls"

@@ -37,4 +37,4 @@ },

"nyc": "^10.0.0",
"snazzy": "^5.0.0"
"xo": "^0.17.1"
}
}

@@ -1,19 +0,22 @@

const addSeconds = require('date-fns/add_seconds')
const isPast = require('date-fns/is_past');
const addSeconds = require('date-fns/add_seconds');
function expired (headers) {
const originDate = new Date(headers.date)
const expired = headers => isPast(expired.on(headers));
expired.on = headers => {
const originDate = new Date(headers.date);
// Get max age ms
let maxAge = headers['cache-control'] && headers['cache-control'].match(/max-age=(\d+)/)
maxAge = parseInt(maxAge ? maxAge[1] : 0)
let maxAge = headers['cache-control'] && headers['cache-control'].match(/max-age=(\d+)/);
maxAge = parseInt(maxAge ? maxAge[1] : 0, 10);
// Take current age into account
if (headers.age) {
maxAge -= headers.age
}
if (headers.age) {
maxAge -= headers.age;
}
// Calculate expirey date
return addSeconds(new Date(originDate), maxAge)
}
return addSeconds(new Date(originDate), maxAge);
};
module.exports = expired
module.exports = expired;
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