This repository was archived by the owner on Dec 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff 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 ( / U R I = [ ' " ] ( .* ?) [ ' " ] / , ( _ , 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
You can’t perform that action at this time.
0 commit comments