From 4286f7eda13c1e698f5b353ef5f4a3fdb351b9bd Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 8 Mar 2024 15:39:43 -0800 Subject: [PATCH] simplify addSuffixToFilePath --- packages/playwright/src/util.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.ts index 505a59c6b6..33f626c59e 100644 --- a/packages/playwright/src/util.ts +++ b/packages/playwright/src/util.ts @@ -195,12 +195,10 @@ export function trimLongString(s: string, length = 100) { return s.substring(0, start) + middle + s.slice(-end); } -export function addSuffixToFilePath(filePath: string, suffix: string, customExtension?: string, sanitize = false): string { - const dirname = path.dirname(filePath); +export function addSuffixToFilePath(filePath: string, suffix: string): string { const ext = path.extname(filePath); - const name = path.basename(filePath, ext); - const base = path.join(dirname, name); - return (sanitize ? sanitizeForFilePath(base) : base) + suffix + (customExtension || ext); + const base = filePath.substring(0, filePath.length - ext.length); + return base + suffix + ext; } /**