fix: resolve frontend lint errors
This commit is contained in:
@@ -632,13 +632,13 @@ export function useAdminFiles() {
|
||||
const storage = detail.storage
|
||||
const expiredAt = policy?.expiredAt ?? policy?.expired_at ?? file.expired_at ?? null
|
||||
const expiredCount = policy?.expiredCount ?? policy?.expired_count ?? file.expired_count ?? null
|
||||
const prefixedName = `${file.prefix || ''}${file.suffix || ''}`
|
||||
const displayName =
|
||||
detail.displayName ??
|
||||
detail.display_name ??
|
||||
detail.filename ??
|
||||
file.name ??
|
||||
`${file.prefix}${file.suffix}` ??
|
||||
file.code
|
||||
(prefixedName || file.code)
|
||||
const normalizedFile: FileListItem = {
|
||||
...file,
|
||||
name: displayName,
|
||||
|
||||
@@ -2,6 +2,11 @@ import { saveAs } from 'file-saver'
|
||||
import type { AdminFileViewItem, ApiResponse, ReceivedFileRecord } from '@/types'
|
||||
import { buildDownloadUrl } from '@/utils/share-url'
|
||||
|
||||
const unsafeFilenamePattern = new RegExp(
|
||||
`[\\\\/:*?"<>|${String.fromCharCode(0)}-${String.fromCharCode(31)}]`,
|
||||
'g'
|
||||
)
|
||||
|
||||
export function downloadReceivedRecord(record: ReceivedFileRecord): void {
|
||||
if (record.downloadUrl) {
|
||||
window.open(buildDownloadUrl(record.downloadUrl), '_blank')
|
||||
@@ -16,7 +21,7 @@ export function downloadReceivedRecord(record: ReceivedFileRecord): void {
|
||||
|
||||
export const getSafeFilename = (name: string) =>
|
||||
name
|
||||
.replace(/[\\/:*?"<>|\x00-\x1F]/g, '_')
|
||||
.replace(unsafeFilenamePattern, '_')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.slice(0, 180) || 'download'
|
||||
|
||||
Reference in New Issue
Block a user