Files
Foundry-VTT-Docker/resources/app/node_modules/@pixi/utils/lib/path.mjs.map

1 line
28 KiB
Plaintext
Raw Normal View History

2025-01-04 00:34:03 +01:00
{"version":3,"file":"path.mjs","sources":["../src/path.ts"],"sourcesContent":["import { settings } from '@pixi/settings';\n\nfunction assertPath(path: string)\n{\n if (typeof path !== 'string')\n {\n throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);\n }\n}\n\nfunction removeUrlParams(url: string): string\n{\n const re = url.split('?')[0];\n\n return re.split('#')[0];\n}\n\nfunction escapeRegExp(string: string)\n{\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nfunction replaceAll(str: string, find: string, replace: string)\n{\n return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);\n}\n\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path: string, allowAboveRoot: boolean)\n{\n let res = '';\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let code = -1;\n\n for (let i = 0; i <= path.length; ++i)\n {\n if (i < path.length)\n {\n code = path.charCodeAt(i);\n }\n else if (code === 47)\n {\n break;\n }\n else\n {\n code = 47;\n }\n if (code === 47)\n {\n if (lastSlash === i - 1 || dots === 1)\n {\n // NOOP\n }\n else if (lastSlash !== i - 1 && dots === 2)\n {\n if (\n res.length < 2\n || lastSegmentLength !== 2\n || res.charCodeAt(res.length - 1) !== 46\n || res.charCodeAt(res.length - 2) !== 46\n )\n {\n if (res.length > 2)\n {\n const lastSlashIndex = res.lastIndexOf('/');\n\n if (lastSlashIndex !== res.length - 1)\n {\n if (lastSlashIndex === -1)\n {\n res = '';\n lastSegmentLength = 0;\n }\n else\n {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n else if (res.length === 2 || res.length === 1)\n {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot)\n {\n if (res.length > 0)\n { res += '/..'; }\n else\n { res = '..'; }\n lastSegmentLength = 2;\n }\n }\n else\n {\n if (res.length > 0)\n {\n res += `/${path.slice(lastSlash + 1, i)}`;\n }\n else\n {\n res = path.slice(lastSlash + 1, i);\n }\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n }\n else if (code === 46 && dots !== -1)\n {\n ++dots;\n }\n else\n {\n dots = -1;\n }\n }\n\n return res;\n}\n\nexport interface Path\n{\n toPosix: (path: string) => string;\n toAbsolute: (url: string, baseUrl?: string, rootUrl?: string) => string;\n isUrl: (path: string) => boolean;\n isDataUrl: (path: string) => boolean;\n isBlobUrl: (path: string) => boolean;\n hasProtocol: