@@ -33,29 +33,6 @@ export async function handleFetch(
3333) {
3434 try {
3535 const requestUrl = new URL ( request . url ) ;
36- let workerType = "" ;
37- if ( requestUrl . searchParams . has ( "type" ) ) {
38- workerType = requestUrl . searchParams . get ( "type" ) as string ;
39- requestUrl . searchParams . delete ( "type" ) ;
40- }
41- if ( requestUrl . searchParams . has ( "dest" ) ) {
42- requestUrl . searchParams . delete ( "dest" ) ;
43- }
44-
45- let meta : URLMeta = { } ;
46- if ( client ) {
47- meta . base = new URL ( unrewriteUrl ( client . url ) ) ;
48- meta . origin = new URL ( unrewriteUrl ( client . url ) ) ;
49- } else {
50- meta . base = new URL ( unrewriteUrl ( request . url ) ) ;
51- meta . origin = new URL ( unrewriteUrl ( request . url ) ) ;
52- }
53- if ( requestUrl . searchParams . has ( "topFrame" ) ) {
54- meta . topFrameName = requestUrl . searchParams . get ( "topFrame" ) ;
55- }
56- if ( requestUrl . searchParams . has ( "parentFrame" ) ) {
57- meta . parentFrameName = requestUrl . searchParams . get ( "parentFrame" ) ;
58- }
5936
6037 if ( requestUrl . pathname === this . config . files . wasm ) {
6138 return fetch ( this . config . files . wasm ) . then ( async ( x ) => {
@@ -80,6 +57,27 @@ export async function handleFetch(
8057 } ) ;
8158 }
8259
60+ let workerType = "" ;
61+ if ( requestUrl . searchParams . has ( "type" ) ) {
62+ workerType = requestUrl . searchParams . get ( "type" ) as string ;
63+ requestUrl . searchParams . delete ( "type" ) ;
64+ }
65+ if ( requestUrl . searchParams . has ( "dest" ) ) {
66+ requestUrl . searchParams . delete ( "dest" ) ;
67+ }
68+ const url = new URL ( unrewriteUrl ( requestUrl ) ) ;
69+
70+ let meta : URLMeta = {
71+ origin : url ,
72+ base : url ,
73+ } ;
74+ if ( requestUrl . searchParams . has ( "topFrame" ) ) {
75+ meta . topFrameName = requestUrl . searchParams . get ( "topFrame" ) ;
76+ }
77+ if ( requestUrl . searchParams . has ( "parentFrame" ) ) {
78+ meta . parentFrameName = requestUrl . searchParams . get ( "parentFrame" ) ;
79+ }
80+
8381 if (
8482 requestUrl . pathname . startsWith ( `${ this . config . prefix } blob:` ) ||
8583 requestUrl . pathname . startsWith ( `${ this . config . prefix } data:` )
@@ -117,8 +115,6 @@ export async function handleFetch(
117115 } ) ;
118116 }
119117
120- const url = new URL ( unrewriteUrl ( requestUrl ) ) ;
121-
122118 const activeWorker : FakeServiceWorker | null = this . serviceWorkers . find (
123119 ( w ) => w . origin === url . origin
124120 ) ;
0 commit comments