Mattermost: avoid raw fetch in monitor media download
This commit is contained in:
@@ -27,6 +27,7 @@ export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promis
|
||||
type FetchMediaOptions = {
|
||||
url: string;
|
||||
fetchImpl?: FetchLike;
|
||||
requestInit?: RequestInit;
|
||||
filePathHint?: string;
|
||||
maxBytes?: number;
|
||||
maxRedirects?: number;
|
||||
@@ -79,7 +80,16 @@ async function readErrorBodySnippet(res: Response, maxChars = 200): Promise<stri
|
||||
}
|
||||
|
||||
export async function fetchRemoteMedia(options: FetchMediaOptions): Promise<FetchMediaResult> {
|
||||
const { url, fetchImpl, filePathHint, maxBytes, maxRedirects, ssrfPolicy, lookupFn } = options;
|
||||
const {
|
||||
url,
|
||||
fetchImpl,
|
||||
requestInit,
|
||||
filePathHint,
|
||||
maxBytes,
|
||||
maxRedirects,
|
||||
ssrfPolicy,
|
||||
lookupFn,
|
||||
} = options;
|
||||
|
||||
let res: Response;
|
||||
let finalUrl = url;
|
||||
@@ -88,6 +98,7 @@ export async function fetchRemoteMedia(options: FetchMediaOptions): Promise<Fetc
|
||||
const result = await fetchWithSsrFGuard({
|
||||
url,
|
||||
fetchImpl,
|
||||
init: requestInit,
|
||||
maxRedirects,
|
||||
policy: ssrfPolicy,
|
||||
lookupFn,
|
||||
|
||||
Reference in New Issue
Block a user