handle lower case am/pm in macos screenshot names (#3194)
This commit is contained in:
@@ -9,7 +9,7 @@ function normalizeUnicodeSpaces(str: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tryMacOSScreenshotPath(filePath: string): string {
|
function tryMacOSScreenshotPath(filePath: string): string {
|
||||||
return filePath.replace(/ (AM|PM)\./g, `${NARROW_NO_BREAK_SPACE}$1.`);
|
return filePath.replace(/ (AM|PM)\./gi, `${NARROW_NO_BREAK_SPACE}$1.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryNFDVariant(filePath: string): string {
|
function tryNFDVariant(filePath: string): string {
|
||||||
|
|||||||
@@ -143,5 +143,20 @@ describe("path-utils", () => {
|
|||||||
// This works because tryMacOSScreenshotPath() handles this case
|
// This works because tryMacOSScreenshotPath() handles this case
|
||||||
expect(result).toBe(join(tempDir, macosName));
|
expect(result).toBe(join(tempDir, macosName));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle macOS screenshot lowercase am/pm variant (en_AU locale)", () => {
|
||||||
|
// Some locales like en_AU use lowercase am/pm in screenshot names
|
||||||
|
const macosName = "Screenshot 2024-01-01 at 10.00.00\u202Fam.png"; // U+202F + lowercase
|
||||||
|
const userName = "Screenshot 2024-01-01 at 10.00.00 am.png"; // regular space + lowercase
|
||||||
|
|
||||||
|
// Create file with macOS-style name
|
||||||
|
writeFileSync(join(tempDir, macosName), "content");
|
||||||
|
|
||||||
|
// User provides regular space path
|
||||||
|
const result = resolveReadPath(userName, tempDir);
|
||||||
|
|
||||||
|
// This works because tryMacOSScreenshotPath() uses case-insensitive matching
|
||||||
|
expect(result).toBe(join(tempDir, macosName));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user