forked from coracle/flotilla
Force url extension for encrypted uploads
This commit is contained in:
@@ -750,6 +750,7 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ext = "." + type.split("/")[1]
|
||||||
const server = await getBlossomServer(options)
|
const server = await getBlossomServer(options)
|
||||||
const hashes = [await sha256(await file.arrayBuffer())]
|
const hashes = [await sha256(await file.arrayBuffer())]
|
||||||
const $signer = signer.get() || Nip01Signer.ephemeral()
|
const $signer = signer.get() || Nip01Signer.ephemeral()
|
||||||
@@ -764,9 +765,11 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
|||||||
return {error: text}
|
return {error: text}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always append file extension if missing
|
// Always append correct file extension if we encrypted the file, or if it's missing
|
||||||
if (new URL(url).pathname.split(".").length === 1) {
|
if (options.encrypt) {
|
||||||
url += "." + type.split("/")[1]
|
url = url.replace(/\.\w+$/, "") + ext
|
||||||
|
} else if (new URL(url).pathname.split(".").length === 1) {
|
||||||
|
url += ext
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = {...task, tags, url}
|
const result = {...task, tags, url}
|
||||||
|
|||||||
Reference in New Issue
Block a user