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

staticify

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

staticify - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

34

index.js

@@ -9,2 +9,3 @@ 'use strict';

const ignoredDirectories = require('ignore-by-default').directories();
const memoizee = require('memoizee');
const send = require('send');

@@ -32,2 +33,14 @@

const cachedMakeHash = memoizee(filePath => {
const fileStr = fs.readFileSync(filePath, 'utf8');
let hash = crypto.createHash('md5')
.update(fileStr, 'utf8')
.digest('hex');
if (opts.shortHash) {
hash = hash.slice(0, 7);
}
return hash;
});
// Walks the directory tree, finding files, generating a version hash

@@ -45,18 +58,9 @@ const buildVersionHash = (directory, root, vers) => {

files.forEach(file => {
const filePath = path.posix.join(directory, file);
const stat = fs.statSync(filePath);
const absFilePath = path.posix.join(directory, file);
const stat = fs.statSync(absFilePath);
if (stat.isDirectory()) {
buildVersionHash(filePath, root, vers); // Whee!
buildVersionHash(absFilePath, root, vers); // Whee!
} else if (stat.isFile()) {
const fileStr = fs.readFileSync(filePath, 'utf8');
let hash = crypto.createHash('md5')
.update(fileStr, 'utf8')
.digest('hex');
if (opts.shortHash) {
hash = hash.slice(0, 7);
}
vers[`/${path.posix.relative(root, filePath)}`] = hash;
vers[`/${path.posix.relative(root, absFilePath)}`] = {absFilePath};
}

@@ -78,5 +82,5 @@ });

const fileNameParts = fileName.split('.');
const {absFilePath} = versions[p];
fileNameParts.push(cachedMakeHash(absFilePath), fileNameParts.pop());
fileNameParts.push(versions[p], fileNameParts.pop());
return path.posix.join(opts.pathPrefix, path.dirname(p), fileNameParts.join('.'));

@@ -83,0 +87,0 @@ };

{
"name": "staticify",
"version": "3.0.0",
"description": "A better static asset handler for Node.js / express.js",
"version": "3.1.0",
"description": "A better static asset handler for Node.js/Express.js",
"main": "index.js",

@@ -30,2 +30,3 @@ "author": "Rakesh Pai <rakeshpai@errorception.com>",

"ignore-by-default": "^1.0.1",
"memoizee": "^0.4.14",
"send": "^0.16.2"

@@ -35,4 +36,4 @@ },

"mocha": "^5.2.0",
"should": "^13.2.1",
"xo": "^0.21.1"
"should": "^13.2.3",
"xo": "^0.23.0"
},

@@ -39,0 +40,0 @@ "xo": {

@@ -9,3 +9,3 @@ # staticify

A better static asset handler for Node.js / express.js.
A better static asset handler for Node.js/Express.js.

@@ -12,0 +12,0 @@ Provides helpers to add a version identifier to your static asset's public URLs, and to remove the hash before serving the file from the file system.

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