{"version":3,"file":"is-parent-path.mjs","names":[],"sources":["../src/is-parent-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n                       ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website:                  https://stormsoftware.com\n Repository:               https://github.com/storm-software/stryke\n Documentation:            https://docs.stormsoftware.com/projects/stryke\n Contact:                  https://stormsoftware.com/contact\n\n SPDX-License-Identifier:  Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { slash } from \"./slash\";\n\n/**\n * Check if a given path is a parent of another path.\n *\n * @example\n * ```ts\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project\");\n * // returns true\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/other\");\n * // returns false\n * isParentPath(\"/home/user/project/src/index.ts\", \"/home/user/project/src/index.ts\");\n * // returns false\n * ```\n *\n * @param childPath - The path to check if it is a child of the parent path.\n * @param parentPath - The path to check if it is a parent of the child path.\n * @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.\n */\nexport function isParentPath(childPath: string, parentPath: string): boolean {\n  const normalizedChild = slash(\n    childPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n  )?.toLowerCase();\n  const normalizedParent = slash(\n    parentPath.replaceAll(/\\\\/g, \"/\").replace(/\\/*$/, \"\")\n  )?.toLowerCase();\n\n  return (\n    childPath !== parentPath &&\n    normalizedChild !== normalizedParent &&\n    normalizedChild.startsWith(`${normalizedParent}/`)\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,aAAa,WAAmB,YAA6B;CAC3E,MAAM,kBAAkB,MACtB,UAAU,WAAW,OAAO,IAAI,CAAC,QAAQ,QAAQ,GAAG,CACrD,EAAE,aAAa;CAChB,MAAM,mBAAmB,MACvB,WAAW,WAAW,OAAO,IAAI,CAAC,QAAQ,QAAQ,GAAG,CACtD,EAAE,aAAa;AAEhB,QACE,cAAc,cACd,oBAAoB,oBACpB,gBAAgB,WAAW,GAAG,iBAAiB,GAAG"}