fix: Fixed issue where files would not download correctly on mobile if they had special characters in the name

This commit is contained in:
Aman Harwara
2023-07-10 20:27:52 +05:30
parent 5c87f3a3b4
commit de6994f743
2 changed files with 12 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ import ImagePreview from './ImagePreview'
import { ImageZoomLevelProps } from './ImageZoomLevelProps'
import { PreviewableTextFileTypes, RequiresNativeFilePreview } from './isFilePreviewable'
import TextPreview from './TextPreview'
import { parseFileName } from '@standardnotes/filepicker'
import { sanitizeFileName } from '@standardnotes/ui-services'
type Props = {
application: WebApplication
@@ -55,7 +57,11 @@ const PreviewComponent: FunctionComponent<Props> = ({
}),
)
void application.mobileDevice().previewFile(fileBase64, file.name)
const { name, ext } = parseFileName(file.name)
const sanitizedName = sanitizeFileName(name)
const filename = `${sanitizedName}.${ext}`
void application.mobileDevice().previewFile(fileBase64, filename)
}, [application, bytes, file.mimeType, file.name, isNativeMobileWeb])
if (isNativeMobileWeb && requiresNativePreview) {