Skip to content

Commit a94bf40

Browse files
committed
fix: wrongly parsing text files into arrays
1 parent 87f2873 commit a94bf40

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

app/components/Generate.vue

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ onMounted(() => {
6262
<span text-right md:text-left>{{ count }}</span>
6363
<span text-neutral-500>FPS</span>
6464
<span text-right md:text-left>{{ framePerSecond.toFixed(2) }}</span>
65+
<span text-neutral-500>Filename</span>
66+
<span text-right md:text-left>{{ props.filename }}</span>
67+
<span text-neutral-500>Content Type</span>
68+
<span text-right md:text-left>{{ props.contentType }}</span>
6569
</div>
6670
</Collapsable>
6771
<div

app/components/Scan.vue

+3-17
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,9 @@ function pluse(index: number) {
221221
el.style.filter = 'none'
222222
}
223223
224-
/**
225-
* Proposed ideal method to convert data to a data URL
226-
*
227-
* @param data - The data to convert
228-
* @param type - The content type of the data
229-
*/
230-
function toDataURL(data: Uint8Array | string | any, type: string): string {
231-
if (type.startsWith('text/')) {
232-
return URL.createObjectURL(new Blob([new TextEncoder().encode(data)], { type: 'text/plain' }))
233-
}
234-
else if (type === 'application/json') {
235-
const json = JSON.stringify(data)
236-
return URL.createObjectURL(new Blob([new TextEncoder().encode(json)], { type: 'application/json' }))
237-
}
238-
else {
239-
return URL.createObjectURL(new Blob([data], { type: 'application/octet-stream' }))
240-
}
224+
function toDataURL(data: Uint8Array, type: string): string {
225+
type ||= 'application/octet-stream'
226+
return URL.createObjectURL(new Blob([data], { type }))
241227
}
242228
243229
let decoderInitPromise: Promise<any> | undefined

0 commit comments

Comments
 (0)