mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
17 lines
484 B
TypeScript
17 lines
484 B
TypeScript
// This is inspired by the `is-path-inside` module on npm.
|
|
import * as path from '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)
|
|
);
|
|
}
|