Comparing version 4.1.2 to 4.1.4
@@ -35,2 +35,9 @@ #! /usr/bin/env node | ||
// eslint-disable-next-line no-control-regex | ||
const nonUrlSafeCharsRgx = /[\x00-\x1F\x7F-\uFFFF]+/g; | ||
function ensureUriEncoded(text) { | ||
return String(text).replace(nonUrlSafeCharsRgx, encodeURIComponent); | ||
} | ||
// Check to see if we should try to compress a file with gzip. | ||
@@ -168,3 +175,4 @@ function shouldCompressGzip(req) { | ||
return false; | ||
} else if (!opts.weakCompare && (clientEtag !== serverEtag || clientEtag.indexOf('W/') === 0)) { | ||
} | ||
if (!opts.weakCompare && (clientEtag !== serverEtag || clientEtag.indexOf('W/') === 0)) { | ||
return false; | ||
@@ -379,4 +387,6 @@ } | ||
// Try to serve default ./404.html | ||
const rawUrl = (handleError ? `/${path.join(baseDir, `404.${defaultExt}`)}` : req.url); | ||
const encodedUrl = ensureUriEncoded(rawUrl); | ||
middleware({ | ||
url: (handleError ? `/${path.join(baseDir, `404.${defaultExt}`)}` : req.url), | ||
url: encodedUrl, | ||
headers: req.headers, | ||
@@ -399,3 +409,4 @@ statusCode: 404, | ||
const q = parsed.query ? `?${parsed.query}` : ''; | ||
res.setHeader('location', `${parsed.pathname}/${q}`); | ||
const d = `${parsed.pathname}/${q}`; | ||
res.setHeader('location', ensureUriEncoded(d)); | ||
res.end(); | ||
@@ -402,0 +413,0 @@ return; |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple static file server middleware", | ||
"version": "4.1.2", | ||
"version": "4.1.4", | ||
"homepage": "https://github.com/jfhbrook/node-ecstatic", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -0,1 +1,5 @@ | ||
# THIS PROJECT IS UNMAINTAINED AND DEPRECATED | ||
Please use something else. See: https://github.com/jfhbrook/node-ecstatic/issues/259 | ||
# Ecstatic [![build status](https://secure.travis-ci.org/jfhbrook/node-ecstatic.png)](http://travis-ci.org/jfhbrook/node-ecstatic) [![codecov.io](https://codecov.io/github/jfhbrook/node-ecstatic/coverage.svg?branch=master)](https://codecov.io/github/jfhbrook/node-ecstatic?branch=master) | ||
@@ -2,0 +6,0 @@ |
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
318800
30
1341
356