Skip to content

Commit b966dbc

Browse files
fix: format the content of the download csv file (#463)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 4e9cd16 commit b966dbc

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

app/components/PackageDownloadAnalytics.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,20 @@ const config = computed(() => {
486486
)
487487
},
488488
csv: (csvStr: string) => {
489-
const blob = new Blob([csvStr.replace('data:text/csv;charset=utf-8,', '')])
489+
// Extract multiline date format template and replace newlines with spaces in CSV
490+
// This ensures CSV compatibility by converting multiline date ranges to single-line format
491+
const PLACEHOLDER_CHAR = '\0'
492+
const multilineDateTemplate = $t('package.downloads.date_range_multiline', {
493+
start: PLACEHOLDER_CHAR,
494+
end: PLACEHOLDER_CHAR,
495+
})
496+
.replaceAll(PLACEHOLDER_CHAR, '')
497+
.trim()
498+
const blob = new Blob([
499+
csvStr
500+
.replace('data:text/csv;charset=utf-8,', '')
501+
.replaceAll(`\n${multilineDateTemplate}`, ` ${multilineDateTemplate}`),
502+
])
490503
const url = URL.createObjectURL(blob)
491504
loadFile(
492505
url,

0 commit comments

Comments
 (0)