diff --git a/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte b/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte index 3ce444655..bae077b9b 100644 --- a/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte +++ b/src/lib/components/chat/MessageInput/Commands/Knowledge.svelte @@ -154,6 +154,14 @@ keys: ['name', 'description'] }); }); + + const decodeString = (str: string) => { + try { + return decodeURIComponent(str); + } catch (e) { + return str; + } + }; {#if filteredItems.length > 0 || prompt.split(' ')?.at(0)?.substring(1).startsWith('http')} @@ -210,7 +218,7 @@ {/if}
- {decodeURIComponent(item?.name)} + {decodeString(item?.name)}
diff --git a/src/lib/components/chat/Messages/Citations.svelte b/src/lib/components/chat/Messages/Citations.svelte index 5c6ebbc10..8c2fbf799 100644 --- a/src/lib/components/chat/Messages/Citations.svelte +++ b/src/lib/components/chat/Messages/Citations.svelte @@ -87,6 +87,14 @@ showRelevance = calculateShowRelevance(citations); showPercentage = shouldShowPercentage(citations); } + + const decodeString = (str: string) => { + try { + return decodeURIComponent(str); + } catch (e) { + return str; + } + }; - {decodeURIComponent(citation.source.name)} + {decodeString(citation.source.name)} {/each} @@ -157,7 +165,7 @@ {/if}
- {decodeURIComponent(citation.source.name)} + {decodeString(citation.source.name)}
{/each} @@ -194,7 +202,7 @@ {/if}
- {decodeURIComponent(citation.source.name)} + {decodeString(citation.source.name)}
{/each} diff --git a/src/lib/components/chat/Messages/CitationsModal.svelte b/src/lib/components/chat/Messages/CitationsModal.svelte index c77a8193b..174d80c4f 100644 --- a/src/lib/components/chat/Messages/CitationsModal.svelte +++ b/src/lib/components/chat/Messages/CitationsModal.svelte @@ -45,6 +45,14 @@ ); } } + + const decodeString = (str: string) => { + try { + return decodeURIComponent(str); + } catch (e) { + return str; + } + }; @@ -99,7 +107,7 @@ : `#`} target="_blank" > - {decodeURIComponent(document?.metadata?.name ?? document.source.name)} + {decodeString(document?.metadata?.name ?? document.source.name)} {#if document?.metadata?.page} diff --git a/src/lib/components/common/FileItem.svelte b/src/lib/components/common/FileItem.svelte index 772b07858..fda00046a 100644 --- a/src/lib/components/common/FileItem.svelte +++ b/src/lib/components/common/FileItem.svelte @@ -28,6 +28,14 @@ import { deleteFileById } from '$lib/apis/files'; let showModal = false; + + const decodeString = (str: string) => { + try { + return decodeURIComponent(str); + } catch (e) { + return str; + } + }; {#if item} @@ -82,7 +90,7 @@ {#if !small}
- {decodeURIComponent(name)} + {decodeString(name)}
@@ -101,11 +109,7 @@
{:else} - +
{#if loading} @@ -113,7 +117,7 @@
{/if} -
{decodeURIComponent(name)}
+
{decodeString(name)}
{formatFileSize(size)}
diff --git a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte index c6f47e8de..dc0e354ec 100644 --- a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte +++ b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte @@ -547,6 +547,14 @@ dropZone?.removeEventListener('drop', onDrop); dropZone?.removeEventListener('dragleave', onDragLeave); }); + + const decodeString = (str: string) => { + try { + return decodeURIComponent(str); + } catch (e) { + return str; + } + }; {#if dragged} @@ -698,7 +706,7 @@ href={selectedFile.id ? `/api/v1/files/${selectedFile.id}/content` : '#'} target="_blank" > - {decodeURIComponent(selectedFile?.meta?.name)} + {decodeString(selectedFile?.meta?.name)}