Comparing version 3.2.0 to 3.3.0
18
index.js
@@ -16,5 +16,3 @@ 'use strict'; | ||
const setOptions = opts => { | ||
opts = opts || {}; | ||
const setOptions = (opts = {}) => { | ||
let defaultOptions = { | ||
@@ -50,2 +48,3 @@ includeAll: opts.includeAll || false, | ||
} | ||
return hash; | ||
@@ -55,6 +54,3 @@ }); | ||
// Walks the directory tree, finding files, generating a version hash | ||
const buildVersionHash = (directory, root, vers) => { | ||
root = root || directory; | ||
vers = vers || {}; | ||
const buildVersionHash = (directory, root = directory, vers = {}) => { | ||
if (opts.includeAll === false && ignoredDirectories.some(d => directory.includes(d))) { | ||
@@ -119,2 +115,3 @@ return; | ||
const serve = req => { | ||
// eslint-disable-next-line node/no-deprecated-api | ||
const filePath = stripVersion(url.parse(req.url).pathname); | ||
@@ -136,2 +133,3 @@ const sendOpts = filePath === req.url ? sendOptsNonVersioned : opts.sendOptions; | ||
} | ||
return next(err); | ||
@@ -143,4 +141,6 @@ }) | ||
const replacePaths = fileContents => { | ||
return Object.keys(versions).reduce((f, url) => { | ||
return f.replace(url, getVersionedPath(url)); | ||
return Object.keys(versions).sort((a, b) => { | ||
return b.length - a.length; | ||
}).reduce((f, url) => { | ||
return f.replace(new RegExp(url, 'g'), getVersionedPath(url)); | ||
}, fileContents); | ||
@@ -147,0 +147,0 @@ }; |
{ | ||
"name": "staticify", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "A better static asset handler for Node.js/Express.js", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"mocha": "mocha", | ||
"mocha": "mocha --exit", | ||
"xo": "xo", | ||
@@ -37,7 +37,7 @@ "test": "npm run xo && npm run mocha", | ||
"devDependencies": { | ||
"coveralls": "^3.0.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"coveralls": "^3.0.3", | ||
"mocha": "^6.0.2", | ||
"nyc": "^13.3.0", | ||
"should": "^13.2.3", | ||
"xo": "^0.23.0" | ||
"xo": "^0.24.0" | ||
}, | ||
@@ -44,0 +44,0 @@ "engines": { |
# staticify | ||
[![NPM version](https://img.shields.io/npm/v/staticify.svg)](https://www.npmjs.com/package/staticify) | ||
[![Linux Build Status](https://img.shields.io/travis/errorception/staticify/master.svg?label=Linux%20build)](https://travis-ci.org/errorception/staticify) | ||
[![Windows Build status](https://img.shields.io/appveyor/ci/rakeshpai/staticify/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/rakeshpai/staticify/branch/master) | ||
[![Build Status](https://img.shields.io/travis/errorception/staticify/master.svg?label=Build%20Status)](https://travis-ci.org/errorception/staticify) | ||
[![Coverage Status](https://img.shields.io/coveralls/github/errorception/staticify/master.svg)](https://coveralls.io/github/errorception/staticify?branch=master) | ||
@@ -7,0 +6,0 @@ [![dependencies Status](https://img.shields.io/david/errorception/staticify.svg)](https://david-dm.org/errorception/staticify) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12052
181