fix lint warnings and errors in fetch.ts

This commit is contained in:
wearrrrr 2024-10-10 20:23:28 -05:00
parent 257756f998
commit 1147aea917

View file

@ -1,6 +1,4 @@
import { BareHeaders, BareResponseFetch } from "@mercuryworkshop/bare-mux"; import { BareResponseFetch } from "@mercuryworkshop/bare-mux";
import IDBMap from "@webreflection/idb-map";
import { ParseResultType } from "parse-domain";
import { MessageW2C, ScramjetServiceWorker } from "."; import { MessageW2C, ScramjetServiceWorker } from ".";
import { renderError } from "./error"; import { renderError } from "./error";
import { FakeServiceWorker } from "./fakesw"; import { FakeServiceWorker } from "./fakesw";
@ -17,7 +15,6 @@ import {
} from "../shared"; } from "../shared";
import type { URLMeta } from "../shared/rewriters/url"; import type { URLMeta } from "../shared/rewriters/url";
import { Readable } from "stream";
function newmeta(url: URL): URLMeta { function newmeta(url: URL): URLMeta {
return { return {
@ -80,12 +77,12 @@ export async function swfetch(
new URL(client.url).pathname.startsWith(self.$scramjet.config.prefix) new URL(client.url).pathname.startsWith(self.$scramjet.config.prefix)
) { ) {
// TODO: i was against cors emulation but we might actually break stuff if we send full origin/referrer always // TODO: i was against cors emulation but we might actually break stuff if we send full origin/referrer always
const url = new URL(decodeUrl(client.url)); const clientURL = new URL(decodeUrl(client.url));
if (url.toString().includes("youtube.com")) { if (clientURL.toString().includes("youtube.com")) {
// console.log(headers); // console.log(headers);
} else { } else {
headers.set("Referer", url.toString()); headers.set("Referer", clientURL.toString());
headers.set("Origin", url.origin); headers.set("Origin", clientURL.origin);
} }
} }