mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
lint: src/node/utils/AbsolutePaths.js
This commit is contained in:
parent
7afc809073
commit
60bc849be2
1 changed files with 6 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
'use strict';
|
||||||
/**
|
/**
|
||||||
* Library for deterministic relative filename expansion for Etherpad.
|
* Library for deterministic relative filename expansion for Etherpad.
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +41,7 @@ let etherpadRoot = null;
|
||||||
* @return {string[]|boolean} The shortened array, or false if there was no
|
* @return {string[]|boolean} The shortened array, or false if there was no
|
||||||
* overlap.
|
* overlap.
|
||||||
*/
|
*/
|
||||||
const popIfEndsWith = function (stringArray, lastDesiredElements) {
|
const popIfEndsWith = (stringArray, lastDesiredElements) => {
|
||||||
if (stringArray.length <= lastDesiredElements.length) {
|
if (stringArray.length <= lastDesiredElements.length) {
|
||||||
absPathLogger.debug(`In order to pop "${lastDesiredElements.join(path.sep)}" from "${stringArray.join(path.sep)}", it should contain at least ${lastDesiredElements.length + 1} elements`);
|
absPathLogger.debug(`In order to pop "${lastDesiredElements.join(path.sep)}" from "${stringArray.join(path.sep)}", it should contain at least ${lastDesiredElements.length + 1} elements`);
|
||||||
|
|
||||||
|
@ -72,8 +73,8 @@ const popIfEndsWith = function (stringArray, lastDesiredElements) {
|
||||||
* @return {string} The identified absolute base path. If such path cannot be
|
* @return {string} The identified absolute base path. If such path cannot be
|
||||||
* identified, prints a log and exits the application.
|
* identified, prints a log and exits the application.
|
||||||
*/
|
*/
|
||||||
exports.findEtherpadRoot = function () {
|
exports.findEtherpadRoot = () => {
|
||||||
if (etherpadRoot !== null) {
|
if (etherpadRoot != null) {
|
||||||
return etherpadRoot;
|
return etherpadRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ exports.findEtherpadRoot = function () {
|
||||||
* it is returned unchanged. Otherwise it is interpreted
|
* it is returned unchanged. Otherwise it is interpreted
|
||||||
* relative to exports.root.
|
* relative to exports.root.
|
||||||
*/
|
*/
|
||||||
exports.makeAbsolute = function (somePath) {
|
exports.makeAbsolute = (somePath) => {
|
||||||
if (path.isAbsolute(somePath)) {
|
if (path.isAbsolute(somePath)) {
|
||||||
return somePath;
|
return somePath;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +146,7 @@ exports.makeAbsolute = function (somePath) {
|
||||||
* a subdirectory of the base one
|
* a subdirectory of the base one
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
exports.isSubdir = function (parent, arbitraryDir) {
|
exports.isSubdir = (parent, arbitraryDir) => {
|
||||||
// modified from: https://stackoverflow.com/questions/37521893/determine-if-a-path-is-subdirectory-of-another-in-node-js#45242825
|
// modified from: https://stackoverflow.com/questions/37521893/determine-if-a-path-is-subdirectory-of-another-in-node-js#45242825
|
||||||
const relative = path.relative(parent, arbitraryDir);
|
const relative = path.relative(parent, arbitraryDir);
|
||||||
const isSubdir = !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
const isSubdir = !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
||||||
|
|
Loading…
Reference in a new issue