fix: handle dotted reserved snapshot names

This commit is contained in:
Affaan Mustafa
2026-04-30 12:14:45 -04:00
committed by Affaan Mustafa
parent 61992f7f5e
commit 841beea45c
2 changed files with 19 additions and 7 deletions

View File

@@ -626,7 +626,12 @@ function sanitizeSnapshotName(value, fallback = 'session') {
return sanitized;
}
if (sanitized && isWindowsReservedBasename(sanitized)) {
return `${sanitized}-${hashString(raw).slice(0, 8)}`;
const firstDotIndex = sanitized.indexOf('.');
const hashSuffix = hashString(raw).slice(0, 8);
if (firstDotIndex === -1) {
return `${sanitized}-${hashSuffix}`;
}
return `${sanitized.slice(0, firstDotIndex)}-${hashSuffix}${sanitized.slice(firstDotIndex)}`;
}
const prefix = sanitized ? sanitized.slice(0, 48).replace(/[._-]+$/g, '') : fallback;