Complete code coverage for emoji sprite sheet
This commit is contained in:
parent
fbf51dab64
commit
235aee3fef
1 changed files with 1 additions and 4 deletions
|
@ -32,6 +32,7 @@ async function compositeMatrixEmojis(mxcs) {
|
||||||
// @ts-ignore the signal is slightly different from the type it wants (still works fine)
|
// @ts-ignore the signal is slightly different from the type it wants (still works fine)
|
||||||
const res = await fetch(url, {agent: false, signal: abortController.signal})
|
const res = await fetch(url, {agent: false, signal: abortController.signal})
|
||||||
const {stream, mime} = await streamMimeType.getMimeType(res.body)
|
const {stream, mime} = await streamMimeType.getMimeType(res.body)
|
||||||
|
assert(["image/png", "image/jpeg", "image/webp", "image/gif"].includes(mime), `Mime type ${mime} is impossible for emojis`)
|
||||||
|
|
||||||
if (mime === "image/png" || mime === "image/jpeg" || mime === "image/webp") {
|
if (mime === "image/png" || mime === "image/jpeg" || mime === "image/webp") {
|
||||||
/** @type {{info: sharp.OutputInfo, buffer: Buffer}} */
|
/** @type {{info: sharp.OutputInfo, buffer: Buffer}} */
|
||||||
|
@ -64,10 +65,6 @@ async function compositeMatrixEmojis(mxcs) {
|
||||||
.toBuffer({resolveWithObject: true})
|
.toBuffer({resolveWithObject: true})
|
||||||
return buffer.data
|
return buffer.data
|
||||||
|
|
||||||
} else {
|
|
||||||
// unsupported mime type
|
|
||||||
console.error(`I don't know what a ${mime} emoji is.`)
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
abortController.abort()
|
abortController.abort()
|
||||||
|
|
Loading…
Reference in a new issue