Remove unnecessary path.normalize() calls

`path.join()` already normalizes.
This commit is contained in:
Richard Hansen 2021-02-10 01:12:43 -05:00 committed by John McLear
parent 84c1d74f8b
commit f868788417
6 changed files with 9 additions and 10 deletions

View file

@ -101,7 +101,7 @@ const minify = async (req, res) => {
let filename = req.params.filename;
// No relative paths, especially if they may go up the file hierarchy.
filename = path.normalize(path.join(ROOT_DIR, filename));
filename = path.join(ROOT_DIR, filename);
filename = filename.replace(/\.\./g, '');
if (filename.indexOf(ROOT_DIR) === 0) {
@ -198,7 +198,7 @@ const getAceFile = async () => {
await Promise.all(filenames.map(async (filename) => {
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
const baseURI = 'http://invalid.invalid';
let resourceURI = baseURI + path.normalize(path.join('/static/', filename));
let resourceURI = baseURI + path.join('/static/', filename);
resourceURI = resourceURI.replace(/\\/g, '/'); // Windows (safe generally?)
const [status, , body] = await requestURI(resourceURI, 'GET', {});