@@ -121,21 +121,23 @@ async function downloadSubscription(req, res) {
121121 } ,
122122 } ;
123123 if ( req . query . $options ) {
124+ let options = { } ;
124125 try {
125126 // 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}`
126- $ options = JSON . parse ( decodeURIComponent ( req . query . $options ) ) ;
127+ options = JSON . parse ( decodeURIComponent ( req . query . $options ) ) ;
127128 } catch ( e ) {
128129 for ( const pair of req . query . $options . split ( '&' ) ) {
129130 const key = pair . split ( '=' ) [ 0 ] ;
130131 const value = pair . split ( '=' ) [ 1 ] ;
131132 // 部分兼容之前的逻辑 const value = pair.split('=')[1] || true;
132- $ options[ key ] =
133+ options [ key ] =
133134 value == null || value === ''
134135 ? true
135136 : decodeURIComponent ( value ) ;
136137 }
137138 }
138- $ . info ( `传入 $options: ${ JSON . stringify ( $options ) } ` ) ;
139+ $ . info ( `传入 $options: ${ JSON . stringify ( options ) } ` ) ;
140+ Object . assign ( $options , options ) ;
139141 }
140142 if ( url ) {
141143 $ . info ( `指定远程订阅 URL: ${ url } ` ) ;
@@ -315,12 +317,21 @@ async function downloadSubscription(req, res) {
315317 req . query ,
316318 ) ;
317319 }
318- res . set ( 'Content-Type' , 'application/json;charset=utf-8' ) . send (
319- output ,
320- ) ;
320+ res . set ( 'Content-Type' , 'application/json;charset=utf-8' ) ;
321321 } else {
322- res . send ( output ) ;
322+ res . set ( 'Content-Type' , 'text/plain; charset=utf-8' ) ;
323+ }
324+ if ( $options ?. _res ?. headers ) {
325+ Object . entries ( $options . _res . headers ) . forEach (
326+ ( [ key , value ] ) => {
327+ res . set ( key , value ) ;
328+ } ,
329+ ) ;
330+ }
331+ if ( $options ?. _res ?. status ) {
332+ res . status ( $options . _res . status ) ;
323333 }
334+ res . send ( output ) ;
324335 } catch ( err ) {
325336 $ . notify (
326337 `🌍 Sub-Store 下载订阅失败` ,
@@ -386,21 +397,23 @@ async function downloadCollection(req, res) {
386397 } ,
387398 } ;
388399 if ( req . query . $options ) {
400+ let options = { } ;
389401 try {
390402 // 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}`
391- $ options = JSON . parse ( decodeURIComponent ( req . query . $options ) ) ;
403+ options = JSON . parse ( decodeURIComponent ( req . query . $options ) ) ;
392404 } catch ( e ) {
393405 for ( const pair of req . query . $options . split ( '&' ) ) {
394406 const key = pair . split ( '=' ) [ 0 ] ;
395407 const value = pair . split ( '=' ) [ 1 ] ;
396408 // 部分兼容之前的逻辑 const value = pair.split('=')[1] || true;
397- $ options[ key ] =
409+ options [ key ] =
398410 value == null || value === ''
399411 ? true
400412 : decodeURIComponent ( value ) ;
401413 }
402414 }
403- $ . info ( `传入 $options: ${ JSON . stringify ( $options ) } ` ) ;
415+ $ . info ( `传入 $options: ${ JSON . stringify ( options ) } ` ) ;
416+ Object . assign ( $options , options ) ;
404417 }
405418
406419 if ( proxy ) {
@@ -578,12 +591,21 @@ async function downloadCollection(req, res) {
578591 req . query ,
579592 ) ;
580593 }
581- res . set ( 'Content-Type' , 'application/json;charset=utf-8' ) . send (
582- output ,
583- ) ;
594+ res . set ( 'Content-Type' , 'application/json;charset=utf-8' ) ;
584595 } else {
585- res . send ( output ) ;
596+ res . set ( 'Content-Type' , 'text/plain; charset=utf-8' ) ;
597+ }
598+ if ( $options ?. _res ?. headers ) {
599+ Object . entries ( $options . _res . headers ) . forEach (
600+ ( [ key , value ] ) => {
601+ res . set ( key , value ) ;
602+ } ,
603+ ) ;
604+ }
605+ if ( $options ?. _res ?. status ) {
606+ res . status ( $options . _res . status ) ;
586607 }
608+ res . send ( output ) ;
587609 } catch ( err ) {
588610 $ . notify (
589611 `🌍 Sub-Store 下载组合订阅失败` ,
0 commit comments