mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
23 lines
525 B
TypeScript
23 lines
525 B
TypeScript
import { net } from 'electron';
|
|
|
|
export const getNetFetchAsFetch = () =>
|
|
(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
const url =
|
|
typeof input === 'string'
|
|
? new URL(input)
|
|
: input instanceof URL
|
|
? input
|
|
: new URL(input.url);
|
|
|
|
if (init?.body && !init.method) {
|
|
init.method = 'POST';
|
|
}
|
|
|
|
const request = new Request(
|
|
url,
|
|
input instanceof Request ? input : undefined,
|
|
);
|
|
|
|
return net.fetch(request, init);
|
|
}) as typeof fetch;
|