fix: treat relative dot-paths as file paths in screenshot command

Closes #495
This commit is contained in:
bluzername
2026-03-26 06:14:29 +07:00
parent 9870a4ec49
commit e2b8567abf
2 changed files with 16 additions and 1 deletions

View File

@@ -114,7 +114,11 @@ export async function handleMetaCommand(
// Separate target (selector/@ref) from output path
for (const arg of remaining) {
if (arg.startsWith('@e') || arg.startsWith('@c') || arg.startsWith('.') || arg.startsWith('#') || arg.includes('[')) {
// File paths containing / and ending with an image/pdf extension are never CSS selectors
const isFilePath = arg.includes('/') && /\.(png|jpe?g|webp|pdf)$/i.test(arg);
if (isFilePath) {
outputPath = arg;
} else if (arg.startsWith('@e') || arg.startsWith('@c') || arg.startsWith('.') || arg.startsWith('#') || arg.includes('[')) {
targetSelector = arg;
} else {
outputPath = arg;