Skip to content

Commit

Permalink
🐛 (fileUpload) Fix results file display if name contains comma
Browse files Browse the repository at this point in the history
Closes #955
  • Loading branch information
baptisteArno committed Nov 14, 2023
1 parent fd00b6f commit bd198a4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/builder/src/features/results/components/FileLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const FileLinks = ({ fileNamesStr }: { fileNamesStr: string }) => {
<HStack as={WrapItem} key={name}>
<FileIcon />
<TextLink href={name} isExternal>
{name.split('/').pop()}
{decodeURIComponent(name.split('/').pop() ?? '')}
</TextLink>
</HStack>
))}
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.2.18",
"version": "0.2.19",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { uploadFiles } from '../helpers/uploadFiles'
import { guessApiHost } from '@/utils/guessApiHost'
import { getRuntimeVariable } from '@typebot.io/env/getRuntimeVariable'
import { defaultFileInputOptions } from '@typebot.io/schemas/features/blocks/inputs/file/constants'
import { isDefined } from '@typebot.io/lib'

type Props = {
context: BotContext
Expand Down Expand Up @@ -68,7 +69,10 @@ export const FileUploadForm = (props: Props) => {
})
setIsUploading(false)
if (urls.length)
return props.onSubmit({ label: `File uploaded`, value: urls[0] ?? '' })
return props.onSubmit({
label: `File uploaded`,
value: urls[0] ? encodeURI(urls[0]) : '',
})
setErrorMessage('An error occured while uploading the file')
}
const startFilesUpload = async (files: File[]) => {
Expand Down Expand Up @@ -98,7 +102,7 @@ export const FileUploadForm = (props: Props) => {
return setErrorMessage('An error occured while uploading the files')
props.onSubmit({
label: `${urls.length} file${urls.length > 1 ? 's' : ''} uploaded`,
value: urls.join(', '),
value: urls.filter(isDefined).map(encodeURI).join(', '),
})
}

Expand Down Expand Up @@ -219,7 +223,8 @@ export const FileUploadForm = (props: Props) => {
</Button>
</Show>
<SendButton type="submit" disableIcon>
{props.block.options?.labels?.button ===
{(props.block.options?.labels?.button ??
defaultFileInputOptions.labels.button) ===
defaultFileInputOptions.labels.button
? `Upload ${selectedFiles().length} file${
selectedFiles().length > 1 ? 's' : ''
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.2.18",
"version": "0.2.19",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.2.18",
"version": "0.2.19",
"description": "Convenient library to display typebots on your React app",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit bd198a4

Please sign in to comment.