UNPKG

zephyr-agent

Version:
11 lines (10 loc) • 724 B
import "node:module"; function normalizeSnapshotAssetPath(assetPath) { const normalized = assetPath.replaceAll('\\', '/'); if (!normalized || normalized.includes('\0') || normalized.startsWith('/') || /^[A-Za-z]:/.test(normalized) || /^[A-Za-z][A-Za-z\d+.-]*:\/\//.test(normalized)) throw new Error(`Asset path must be a relative snapshot path: "${assetPath}"`); const segments = normalized.split('/').filter((segment)=>segment && '.' !== segment); if (0 === segments.length || segments.includes('..')) throw new Error(`Asset path must not escape the snapshot root: "${assetPath}"`); return segments.join('/'); } export { normalizeSnapshotAssetPath }; //# sourceMappingURL=ze-snapshot-asset-path.mjs.map