2
0

🚸 (fileUpload) Properly encode commas from uploaded file urls

Closes #955
This commit is contained in:
Baptiste Arnaud
2023-11-28 17:02:25 +01:00
parent 8ce4e4808d
commit 8d413f0865
4 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.2.24",
"version": "0.2.25",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",

View File

@ -71,7 +71,7 @@ export const FileUploadForm = (props: Props) => {
if (urls.length)
return props.onSubmit({
label: `File uploaded`,
value: urls[0] ? encodeURI(urls[0]) : '',
value: urls[0] ? encodeUrl(urls[0]) : '',
})
setErrorMessage('An error occured while uploading the file')
}
@ -102,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.filter(isDefined).map(encodeURI).join(', '),
value: urls.filter(isDefined).map(encodeUrl).join(', '),
})
}
@ -278,3 +278,10 @@ const FileIcon = () => (
<polyline points="13 2 13 9 20 9" />
</svg>
)
const encodeUrl = (url: string): string => {
const fileName = url.split('/').pop()
if (!fileName) return url
const encodedFileName = encodeURIComponent(fileName)
return url.replace(fileName, encodedFileName)
}

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.2.24",
"version": "0.2.25",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.2.24",
"version": "0.2.25",
"description": "Convenient library to display typebots on your React app",
"main": "dist/index.js",
"types": "dist/index.d.ts",