Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit e1948fe

Browse files
committed
supports animepahe links
1 parent ee013e5 commit e1948fe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/proxy.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async function proxy(request) {
128128

129129
const contentType = response.headers.get('content-type') || 'application/octet-stream';
130130
const isM3U8 = videoContentTypes.some((type) => contentType.includes(type));
131-
const responseContent = isM3U8 ? await response.text() : null;
131+
let responseContent = isM3U8 ? await response.text() : null;
132132
const cacheControl = isM3U8 ? getCacheSettings(mediaUrl, responseContent) : CACHE_CONTROL_SETTINGS.SEGMENT;
133133

134134
if (!isM3U8) {
@@ -146,7 +146,16 @@ async function proxy(request) {
146146
await cache.put(cacheKey, newResponse.clone());
147147
return newResponse;
148148
}
149-
149+
responseContent = responseContent.replace(/URI=['"](.*?)['"]/, (_, url) => {
150+
const fullUrl = url.startsWith('http')
151+
? url
152+
: url.startsWith('/')
153+
? `${baseUrl.protocol}//${baseUrl.host}${url}`
154+
: `${basePath}${url}`;
155+
return `URI="${new URL(request.url).origin}/proxy?url=${encodeURIComponent(btoa(fullUrl))}&headers=${encodeURIComponent(
156+
headersBase64
157+
)}"`;
158+
});
150159
const modifiedBody = responseContent.replace(/^(?!#)([^\s]+)$/gm, (match) => {
151160
const fullUrl = match.startsWith('http')
152161
? match

0 commit comments

Comments
 (0)