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 1.2.1 to 1.3.0

2

package.json
{
"name": "expired",
"version": "1.2.1",
"version": "1.3.0",
"description": "Calculate when HTTP responses expire from the cache headers",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -14,5 +14,15 @@ const isBefore = require('date-fns/is_before');

expired.on = headers => {
// Check we have headers
if (!headers) {
throw new Error('Headers argument is missing');
}
// Parse headers if we got a raw string
headers = (typeof headers === 'string') ? parse(headers) : headers;
// Check we have date header
if (!headers.date) {
throw new Error('Date header is missing');
}
// Default to Date header

@@ -19,0 +29,0 @@ let expiredOn = new Date(headers.date);

@@ -6,2 +6,14 @@ import test from 'ava';

test('throw error if header argument is missing', t => {
const err = t.throws(() => expired());
t.is(err.message, 'Headers argument is missing');
});
test('throw error if Date header is missing', t => {
const headers = {};
const err = t.throws(() => expired(headers));
t.is(err.message, 'Date header is missing');
});
test('headers can be passed in as an object', t => {

@@ -8,0 +20,0 @@ const date = new Date().toUTCString();

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