mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-27 00:52:27 +08:00
chore: don't sanitize file extension away (#327)
This commit is contained in:
parent
062cdd0704
commit
2c9376e50f
@ -70,6 +70,13 @@ export async function waitForCompletion<R>(context: Context, page: playwright.Pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sanitizeForFilePath(s: string) {
|
function sanitize(s: string) {
|
||||||
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
|
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function sanitizeForFilePath(s: string) {
|
||||||
|
const separator = s.lastIndexOf('.');
|
||||||
|
if (separator === -1)
|
||||||
|
return sanitize(s);
|
||||||
|
return sanitize(s.substring(0, separator)) + '.' + sanitize(s.substring(separator + 1));
|
||||||
|
}
|
||||||
|
@ -110,14 +110,14 @@ test('clicking on download link emits download', async ({ startClient }, testInf
|
|||||||
url: 'data:text/html,<a href="data:text/plain,Hello world!" download="test.txt">Download</a>',
|
url: 'data:text/html,<a href="data:text/plain,Hello world!" download="test.txt">Download</a>',
|
||||||
},
|
},
|
||||||
})).toContainTextContent('- link "Download" [ref=s1e3]');
|
})).toContainTextContent('- link "Download" [ref=s1e3]');
|
||||||
|
await client.callTool({
|
||||||
await expect.poll(() => client.callTool({
|
|
||||||
name: 'browser_click',
|
name: 'browser_click',
|
||||||
arguments: {
|
arguments: {
|
||||||
element: 'Download link',
|
element: 'Download link',
|
||||||
ref: 's1e3',
|
ref: 's1e3',
|
||||||
},
|
},
|
||||||
})).toContainTextContent(`
|
});
|
||||||
|
await expect.poll(() => client.callTool({ name: 'browser_snapshot', arguments: {} })).toContainTextContent(`
|
||||||
### Downloads
|
### Downloads
|
||||||
- Downloaded file test.txt to ${path.join(outputDir, 'test-txt')}`);
|
- Downloaded file test.txt to ${path.join(outputDir, 'test.txt')}`);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user