1- import { globalOverrides } from "./config" ;
1+ import {
2+ globalOverrides ,
3+ REPLAY_URL_PREFIX ,
4+ REPLAY_URL_PREFIX_REGEXP ,
5+ REPLAY_URL_PREFIX_REGEXP_STR ,
6+ } from "./config" ;
27import { parseUrl } from "./url" ;
38import * as acorn from "acorn" ;
49
@@ -345,7 +350,7 @@ export function completeHtmlRewrite(
345350 const srcMatch = match . match ( / s r c \s * = \s * [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / i) ;
346351 if ( srcMatch && ! srcMatch [ 1 ] . startsWith ( "data:" ) ) {
347352 const fullUrl = parseUrl ( srcMatch [ 1 ] , baseUrl ) ;
348- const proxyUrl = `${ currentOrigin } /w/liveproxy /mp_/${ fullUrl } ` ;
353+ const proxyUrl = `${ currentOrigin } ${ REPLAY_URL_PREFIX } /mp_/${ fullUrl } ` ;
349354 result = result . replace ( srcMatch [ 0 ] , `src="${ proxyUrl } "` ) ;
350355 }
351356 }
@@ -354,7 +359,7 @@ export function completeHtmlRewrite(
354359 const dataSrcMatch = match . match ( / d a t a - s r c \s * = \s * [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / i) ;
355360 if ( dataSrcMatch ) {
356361 const fullUrl = parseUrl ( dataSrcMatch [ 1 ] , baseUrl ) ;
357- const proxyUrl = `${ currentOrigin } /w/liveproxy /mp_/${ fullUrl } ` ;
362+ const proxyUrl = `${ currentOrigin } ${ REPLAY_URL_PREFIX } /mp_/${ fullUrl } ` ;
358363 result = result . replace ( dataSrcMatch [ 0 ] , `data-src="${ proxyUrl } "` ) ;
359364
360365 if (
@@ -382,7 +387,7 @@ export function completeHtmlRewrite(
382387 const [ url , ...rest ] = part . trim ( ) . split ( / \s + / ) ;
383388 if ( url && ! url . startsWith ( "data:" ) ) {
384389 const fullUrl = parseUrl ( url , baseUrl ) ;
385- const proxyUrl = `${ currentOrigin } /w/liveproxy /mp_/${ fullUrl } ` ;
390+ const proxyUrl = `${ currentOrigin } ${ REPLAY_URL_PREFIX } /mp_/${ fullUrl } ` ;
386391 return [ proxyUrl , ...rest ] . join ( " " ) ;
387392 }
388393 return part ;
@@ -485,7 +490,7 @@ export function completeHtmlRewrite(
485490 }
486491
487492 const fullUrl = parseUrl ( poster , baseUrl ) ;
488- const proxyUrl = `${ self . location . origin } /w/liveproxy /mp_/${ fullUrl } ` ;
493+ const proxyUrl = `${ self . location . origin } ${ REPLAY_URL_PREFIX } /mp_/${ fullUrl } ` ;
489494 return match . replace ( poster , proxyUrl ) ;
490495 }
491496 ) ;
@@ -511,7 +516,7 @@ export function completeHtmlRewrite(
511516 }
512517
513518 const fullUrl = parseUrl ( url , baseUrl ) ;
514- const proxyUrl = `${ self . location . origin } /w/liveproxy /mp_/${ fullUrl } ` ;
519+ const proxyUrl = `${ self . location . origin } ${ REPLAY_URL_PREFIX } /mp_/${ fullUrl } ` ;
515520 return match . replace ( url , proxyUrl ) ;
516521 }
517522 ) ;
@@ -550,7 +555,9 @@ export function completeHtmlRewrite(
550555 <script>
551556 ${ liveProxyCode
552557 . replace ( "${originURL}" , baseUrl )
553- . replace ( "${proxyURL}" , self . location . origin ) }
558+ . replace ( "${proxyURL}" , self . location . origin )
559+ . replace ( "${proxyPrefixPath}" , REPLAY_URL_PREFIX )
560+ . replace ( "${proxyPrefixPathRegexpStr}" , REPLAY_URL_PREFIX_REGEXP_STR ) }
554561 </script>
555562 <style>
556563 body {
0 commit comments