fix: Improve performance of base64 detection regex

This commit is contained in:
Tom Moor
2023-10-21 21:29:06 -04:00
parent 0518cdc6d9
commit 9f6c90c86a
3 changed files with 43 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import { Blob } from "buffer";
import { Readable } from "stream";
import { PresignedPost } from "aws-sdk/clients/s3";
import { isBase64Url } from "@shared/utils/urls";
import env from "@server/env";
import Logger from "@server/logging/Logger";
import fetch from "@server/utils/fetch";
@@ -132,7 +133,7 @@ export default abstract class BaseStorage {
}
let buffer, contentType;
const match = url.match(/data:(.*);base64,(.*)/);
const match = isBase64Url(url);
if (match) {
contentType = match[1];