From d091490c0bbd8ede1f119bb98d34e6c4d9ebc8b3 Mon Sep 17 00:00:00 2001 From: Awsum-Al Date: Wed, 13 Nov 2024 14:06:01 -0500 Subject: [PATCH] improve filename sanitization for hash routes This enhancement modifies the filename sanitization process to handle hash-based routing more elegantly. By removing leading underscores from sanitized values, we create cleaner and more readable filenames for Single Page Applications using hash-based navigation. Changes: - Updated getFileOutputPath sanitization to remove leading underscores - Maintains all existing functionality while improving readability - Particularly beneficial for React, Vue, and other SPA frameworks - Preserves path information without unnecessary prefixes Example transformation: Before: _dashboard-2024_11_13.report.html After: dashboard-2024_11_13.report.html --- packages/cli/src/upload/upload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/upload/upload.js b/packages/cli/src/upload/upload.js index f969a4ba6..3c1860b17 100644 --- a/packages/cli/src/upload/upload.js +++ b/packages/cli/src/upload/upload.js @@ -512,7 +512,7 @@ function getFileOutputPath(pattern, context) { for (const match of matches) { const name = match.slice(2, -2).toLowerCase(); const value = context[name] || 'unknown'; - const sanitizedValue = value.replace(/[^a-z0-9]+/gi, '_'); + const sanitizedValue = value.replace(/[^a-z0-9]+/gi, '_').replace(/^_/, ''); filename = filename.replace(match, sanitizedValue); }