Skip to content

Commit

Permalink
handle undefined fileName parameter in route params
Browse files Browse the repository at this point in the history
  • Loading branch information
huult committed Nov 3, 2024
1 parent 1604913 commit 8fac4c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function ImageRenderer({tnode}: ImageRendererProps) {
let fileName = htmlAttribs[CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE] || FileUtils.getFileName(`${isAttachmentOrReceipt ? attachmentSourceAttribute : htmlAttribs.src}`);
const fileInfo = FileUtils.splitExtensionFromFileName(fileName);
if (!fileInfo.fileExtension) {
fileName = `${fileInfo.fileName || CONST.DEFAULT_IMAGE_FILE_NAME}.jpg`;
fileName = `${fileInfo?.fileName || CONST.DEFAULT_IMAGE_FILE_NAME}.jpg`;
}

const thumbnailImageComponent = (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportAttachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ReportAttachments({route}: ReportAttachmentsProps) {
const isAuthTokenRequired = route.params.isAuthTokenRequired;
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const fileName = route.params.fileName;
const fileName = route.params?.fileName;

// In native the imported images sources are of type number. Ref: https://reactnative.dev/docs/image#imagesource
const source = Number(route.params.source) || route.params.source;
Expand Down

0 comments on commit 8fac4c0

Please sign in to comment.