summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-01-20 00:44:46 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-01-20 00:44:46 +0100
commit82e7bf9f96bb334f94a483e9c9de0c5c583a7314 (patch)
treee080e29a7cf9f338b569bfb15339b685dae93a05 /src/util
parentfix: route file regex (#956) (diff)
downloadserver-dev/fix-emoji-uploads.tar.xz
Add detection for gifs when uploading emojis !!UNTESTED!! dev/fix-emoji-uploads
Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util/Array.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util/util/Array.ts b/src/util/util/Array.ts

index 1935fa7a..e1008aa2 100644 --- a/src/util/util/Array.ts +++ b/src/util/util/Array.ts
@@ -19,3 +19,23 @@ export function containsAll(arr: any[], target: any[]) { return target.every((v) => arr.includes(v)); } + +// Rory - 20/01/2023 - Add utility functions to aid with identification of file types in emojis +export function arrayBufferMatchesArr( + haystack: Uint8Array, + needle: number[], + offset: number, +) { + return arrayBufferMatches(haystack, new Uint8Array(needle), 0); +} + +export function arrayBufferMatches( + haystack: Uint8Array, + needle: Uint8Array, + offset: number, +) { + for (let i = 0; i < needle.length; i++) { + if (haystack[i + offset] !== needle[i]) return false; + } + return true; +}