Skip to content

Commit

Permalink
fix: wrongly parsing text files into arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Oct 11, 2024
1 parent 87f2873 commit a94bf40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
4 changes: 4 additions & 0 deletions app/components/Generate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ onMounted(() => {
<span text-right md:text-left>{{ count }}</span>
<span text-neutral-500>FPS</span>
<span text-right md:text-left>{{ framePerSecond.toFixed(2) }}</span>
<span text-neutral-500>Filename</span>
<span text-right md:text-left>{{ props.filename }}</span>
<span text-neutral-500>Content Type</span>
<span text-right md:text-left>{{ props.contentType }}</span>
</div>
</Collapsable>
<div
Expand Down
20 changes: 3 additions & 17 deletions app/components/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,9 @@ function pluse(index: number) {
el.style.filter = 'none'
}
/**
* Proposed ideal method to convert data to a data URL
*
* @param data - The data to convert
* @param type - The content type of the data
*/
function toDataURL(data: Uint8Array | string | any, type: string): string {
if (type.startsWith('text/')) {
return URL.createObjectURL(new Blob([new TextEncoder().encode(data)], { type: 'text/plain' }))
}
else if (type === 'application/json') {
const json = JSON.stringify(data)
return URL.createObjectURL(new Blob([new TextEncoder().encode(json)], { type: 'application/json' }))
}
else {
return URL.createObjectURL(new Blob([data], { type: 'application/octet-stream' }))
}
function toDataURL(data: Uint8Array, type: string): string {
type ||= 'application/octet-stream'
return URL.createObjectURL(new Blob([data], { type }))
}
let decoderInitPromise: Promise<any> | undefined
Expand Down

0 comments on commit a94bf40

Please sign in to comment.