mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Remove unnecessary path.normalize()
calls
`path.join()` already normalizes.
This commit is contained in:
parent
84c1d74f8b
commit
f868788417
6 changed files with 9 additions and 10 deletions
|
@ -29,8 +29,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
res.end(`var specs_list = ${JSON.stringify(files)};\n`);
|
res.end(`var specs_list = ${JSON.stringify(files)};\n`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// path.join seems to normalize by default, but we'll just be explicit
|
const rootTestFolder = path.join(npm.root, '../tests/frontend/');
|
||||||
const rootTestFolder = path.normalize(path.join(npm.root, '../tests/frontend/'));
|
|
||||||
|
|
||||||
const url2FilePath = (url) => {
|
const url2FilePath = (url) => {
|
||||||
let subPath = url.substr('/tests/frontend'.length);
|
let subPath = url.substr('/tests/frontend'.length);
|
||||||
|
@ -39,7 +38,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
}
|
}
|
||||||
subPath = subPath.split('?')[0];
|
subPath = subPath.split('?')[0];
|
||||||
|
|
||||||
let filePath = path.normalize(path.join(rootTestFolder, subPath));
|
let filePath = path.join(rootTestFolder, subPath);
|
||||||
|
|
||||||
// make sure we jail the paths to the test folder, otherwise serve index
|
// make sure we jail the paths to the test folder, otherwise serve index
|
||||||
if (filePath.indexOf(rootTestFolder) !== 0) {
|
if (filePath.indexOf(rootTestFolder) !== 0) {
|
||||||
|
|
|
@ -132,7 +132,7 @@ exports.makeAbsolute = (somePath) => {
|
||||||
return somePath;
|
return somePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rewrittenPath = path.normalize(path.join(exports.findEtherpadRoot(), somePath));
|
const rewrittenPath = path.join(exports.findEtherpadRoot(), somePath);
|
||||||
|
|
||||||
absPathLogger.debug(`Relative path "${somePath}" can be rewritten to "${rewrittenPath}"`);
|
absPathLogger.debug(`Relative path "${somePath}" can be rewritten to "${rewrittenPath}"`);
|
||||||
return rewrittenPath;
|
return rewrittenPath;
|
||||||
|
|
|
@ -101,7 +101,7 @@ const minify = async (req, res) => {
|
||||||
let filename = req.params.filename;
|
let filename = req.params.filename;
|
||||||
|
|
||||||
// No relative paths, especially if they may go up the file hierarchy.
|
// 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, '');
|
filename = filename.replace(/\.\./g, '');
|
||||||
|
|
||||||
if (filename.indexOf(ROOT_DIR) === 0) {
|
if (filename.indexOf(ROOT_DIR) === 0) {
|
||||||
|
@ -198,7 +198,7 @@ const getAceFile = async () => {
|
||||||
await Promise.all(filenames.map(async (filename) => {
|
await Promise.all(filenames.map(async (filename) => {
|
||||||
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
||||||
const baseURI = 'http://invalid.invalid';
|
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?)
|
resourceURI = resourceURI.replace(/\\/g, '/'); // Windows (safe generally?)
|
||||||
|
|
||||||
const [status, , body] = await requestURI(resourceURI, 'GET', {});
|
const [status, , body] = await requestURI(resourceURI, 'GET', {});
|
||||||
|
|
|
@ -719,7 +719,7 @@ exports.reloadSettings = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// informative variable, just for the log messages
|
// informative variable, just for the log messages
|
||||||
let skinPath = path.normalize(path.join(skinBasePath, exports.skinName));
|
let skinPath = path.join(skinBasePath, exports.skinName);
|
||||||
|
|
||||||
// what if someone sets skinName == ".." or "."? We catch him!
|
// what if someone sets skinName == ".." or "."? We catch him!
|
||||||
if (absolutePaths.isSubdir(skinBasePath, skinPath) === false) {
|
if (absolutePaths.isSubdir(skinBasePath, skinPath) === false) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ try {
|
||||||
_crypto = undefined;
|
_crypto = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let CACHE_DIR = path.normalize(path.join(settings.root, 'var/'));
|
let CACHE_DIR = path.join(settings.root, 'var/');
|
||||||
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
||||||
|
|
||||||
const responseCache = {};
|
const responseCache = {};
|
||||||
|
|
|
@ -32,7 +32,7 @@ exports.formatHooks = (hookSetName) => {
|
||||||
const callInit = async () => {
|
const callInit = async () => {
|
||||||
await Promise.all(Object.keys(defs.plugins).map(async (pluginName) => {
|
await Promise.all(Object.keys(defs.plugins).map(async (pluginName) => {
|
||||||
const plugin = defs.plugins[pluginName];
|
const plugin = defs.plugins[pluginName];
|
||||||
const epInit = path.normalize(path.join(plugin.package.path, '.ep_initialized'));
|
const epInit = path.join(plugin.package.path, '.ep_initialized');
|
||||||
try {
|
try {
|
||||||
await fs.stat(epInit);
|
await fs.stat(epInit);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -48,7 +48,7 @@ exports.pathNormalization = (part, hookFnName, hookName) => {
|
||||||
const functionName = (tmp.length > 1 ? tmp.pop() : null) || hookName;
|
const functionName = (tmp.length > 1 ? tmp.pop() : null) || hookName;
|
||||||
const moduleName = tmp.join(':') || part.plugin;
|
const moduleName = tmp.join(':') || part.plugin;
|
||||||
const packageDir = path.dirname(defs.plugins[part.plugin].package.path);
|
const packageDir = path.dirname(defs.plugins[part.plugin].package.path);
|
||||||
const fileName = path.normalize(path.join(packageDir, moduleName));
|
const fileName = path.join(packageDir, moduleName);
|
||||||
return `${fileName}:${functionName}`;
|
return `${fileName}:${functionName}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue