@@ -166,16 +166,25 @@ export default function Shadowrocket_Producer() {
166166 proxy [ 'h2-opts' ] . headers . host = [ host ] ;
167167 }
168168 }
169- if ( proxy . network === 'ws' ) {
170- const wsPath = proxy [ 'ws-opts' ] ?. path ;
171- const reg = / ^ ( .* ?) (?: \? e d = ( \d + ) ) ? $ / ;
172- // eslint-disable-next-line no-unused-vars
173- const [ _ , path = '' , ed = '' ] = reg . exec ( wsPath ) ;
174- proxy [ 'ws-opts' ] . path = path ;
175- if ( ed !== '' ) {
176- proxy [ 'ws-opts' ] [ 'early-data-header-name' ] =
177- 'Sec-WebSocket-Protocol' ;
178- proxy [ 'ws-opts' ] [ 'max-early-data' ] = parseInt ( ed , 10 ) ;
169+ if ( [ 'ws' ] . includes ( proxy . network ) ) {
170+ const networkPath = proxy [ `${ proxy . network } -opts` ] ?. path ;
171+ if ( networkPath ) {
172+ const reg = / ^ ( .* ?) (?: \? e d = ( \d + ) ) ? $ / ;
173+ // eslint-disable-next-line no-unused-vars
174+ const [ _ , path = '' , ed = '' ] = reg . exec ( networkPath ) ;
175+ proxy [ `${ proxy . network } -opts` ] . path = path ;
176+ if ( ed !== '' ) {
177+ proxy [ 'ws-opts' ] [ 'early-data-header-name' ] =
178+ 'Sec-WebSocket-Protocol' ;
179+ proxy [ 'ws-opts' ] [ 'max-early-data' ] = parseInt (
180+ ed ,
181+ 10 ,
182+ ) ;
183+ }
184+ } else {
185+ proxy [ `${ proxy . network } -opts` ] =
186+ proxy [ `${ proxy . network } -opts` ] || { } ;
187+ proxy [ `${ proxy . network } -opts` ] . path = '/' ;
179188 }
180189 }
181190 if ( proxy [ 'plugin-opts' ] ?. tls ) {
0 commit comments