File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 */
66
77import { zod } from '../third_party/index.js' ;
8+ import { ensureExtension } from '../utils/files.js' ;
89
910import { ToolCategory } from './categories.js' ;
1011import { definePageTool } from './ToolDefinition.js' ;
@@ -25,7 +26,7 @@ export const takeMemorySnapshot = definePageTool({
2526 const page = request . page ;
2627
2728 await page . pptrPage . captureHeapSnapshot ( {
28- path : request . params . filePath ,
29+ path : ensureExtension ( request . params . filePath , '.heapsnapshot' ) ,
2930 } ) ;
3031
3132 response . appendResponseLine (
Original file line number Diff line number Diff line change @@ -25,10 +25,10 @@ export async function saveTemporaryFile(
2525 }
2626}
2727
28- export function ensureExtension ( filepath : string , extension : string ) : string {
29- const normalizedExtension = extension . startsWith ( '.' )
30- ? extension
31- : `. ${ extension } ` ;
28+ export function ensureExtension (
29+ filepath : string ,
30+ extension : `.${ string } ` ,
31+ ) : string {
3232 const ext = path . extname ( filepath ) ;
33- return filepath . slice ( 0 , filepath . length - ext . length ) + normalizedExtension ;
33+ return filepath . slice ( 0 , filepath . length - ext . length ) + extension ;
3434}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ describe('ensureExtension', () => {
1919 } ) ;
2020
2121 it ( 'should handle extension without a leading dot' , ( ) => {
22- assert . strictEqual ( ensureExtension ( 'filename' , 'txt' ) , 'filename.txt' ) ;
22+ assert . strictEqual ( ensureExtension ( 'filename' , '. txt' ) , 'filename.txt' ) ;
2323 } ) ;
2424
2525 it ( 'should not add a second dot if already present' , ( ) => {
You can’t perform that action at this time.
0 commit comments