Skip to content

Commit

Permalink
fixed a minor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
real-zephex authored Aug 30, 2024
1 parent 996dd3e commit 1f71593
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/handler/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export async function RequestHandler({ response }: { response: HonoRequest }) {
const { url, ref } = response.query();
const userHeaders = response.header();

let refString = ref ? "&ref=" + encodeURIComponent(ref) : "";

console.log(url);

// fetching content from the remote server using the headers provided by the user
Expand Down Expand Up @@ -46,7 +48,7 @@ export async function RequestHandler({ response }: { response: HonoRequest }) {
const newUrl = url.replace(/\/[^\/]*$/, `/${filename}`);
responseBody = responseBody.replaceAll(
filename,
"/fetch?url=" + newUrl
"/fetch?url=" + newUrl + refString
);
}
}
Expand Down Expand Up @@ -91,7 +93,7 @@ export async function RequestHandler({ response }: { response: HonoRequest }) {
if (formattedLine.match(urlRegex)) {
console.log("TS or M3U8 files with URLs found, adding proxy path");
m3u8AdjustedChunks.push(
`/fetch?url=${encodeURIComponent(formattedLine)}`
`/fetch?url=${encodeURIComponent(formattedLine)}${refString}`
);
} else {
const newUrls = url.replace(
Expand All @@ -101,7 +103,9 @@ export async function RequestHandler({ response }: { response: HonoRequest }) {
console.log(
"TS or M3U8 files with no URLs found, adding path and proxy path."
);
m3u8AdjustedChunks.push(`/fetch?url=${encodeURIComponent(newUrls)}`);
m3u8AdjustedChunks.push(
`/fetch?url=${encodeURIComponent(newUrls)}${refString}`
);
}
// Update URL according to your needs
}
Expand Down

0 comments on commit 1f71593

Please sign in to comment.