mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 18:38:15 +01:00
Rename files
This commit is contained in:
19
ts/util/isPathInside.node.ts
Normal file
19
ts/util/isPathInside.node.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// This is inspired by the `is-path-inside` module on npm.
|
||||
import * as path from 'node:path';
|
||||
|
||||
export function isPathInside(childPath: string, parentPath: string): boolean {
|
||||
const childPathResolved = path.resolve(childPath);
|
||||
|
||||
let parentPathResolved = path.resolve(parentPath);
|
||||
if (!parentPathResolved.endsWith(path.sep)) {
|
||||
parentPathResolved += path.sep;
|
||||
}
|
||||
|
||||
return (
|
||||
childPathResolved !== parentPathResolved &&
|
||||
childPathResolved.startsWith(parentPathResolved)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user