🚸 (fileUpload) Properly encode commas from uploaded file urls
Closes #955
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.2.24",
|
"version": "0.2.25",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export const FileUploadForm = (props: Props) => {
|
|||||||
if (urls.length)
|
if (urls.length)
|
||||||
return props.onSubmit({
|
return props.onSubmit({
|
||||||
label: `File uploaded`,
|
label: `File uploaded`,
|
||||||
value: urls[0] ? encodeURI(urls[0]) : '',
|
value: urls[0] ? encodeUrl(urls[0]) : '',
|
||||||
})
|
})
|
||||||
setErrorMessage('An error occured while uploading the file')
|
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')
|
return setErrorMessage('An error occured while uploading the files')
|
||||||
props.onSubmit({
|
props.onSubmit({
|
||||||
label: `${urls.length} file${urls.length > 1 ? 's' : ''} uploaded`,
|
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" />
|
<polyline points="13 2 13 9 20 9" />
|
||||||
</svg>
|
</svg>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const encodeUrl = (url: string): string => {
|
||||||
|
const fileName = url.split('/').pop()
|
||||||
|
if (!fileName) return url
|
||||||
|
const encodedFileName = encodeURIComponent(fileName)
|
||||||
|
return url.replace(fileName, encodedFileName)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.2.24",
|
"version": "0.2.25",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.2.24",
|
"version": "0.2.25",
|
||||||
"description": "Convenient library to display typebots on your React app",
|
"description": "Convenient library to display typebots on your React app",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user