@@ -719,6 +719,33 @@ function formatTransportPath(path) {
719719}
720720
721721function lastParse ( proxy ) {
722+ // normalize keys to lowercase for all -opts keys and their subkeys
723+ // 通常来说够用了, 在重构之前暂不考虑引入更复杂的逻辑
724+ const hasOwn = ( value , key ) =>
725+ Object . prototype . hasOwnProperty . call ( value , key ) ;
726+ const normalizeOpts = ( value ) => {
727+ if ( ! value || typeof value !== 'object' || Array . isArray ( value ) ) return ;
728+ for ( const key of Object . keys ( value ) ) {
729+ const normalizedKey = key . toLowerCase ( ) ;
730+ if ( key !== normalizedKey ) {
731+ if ( ! hasOwn ( value , normalizedKey ) ) {
732+ value [ normalizedKey ] = value [ key ] ;
733+ }
734+ delete value [ key ] ;
735+ }
736+ }
737+ } ;
738+ for ( const key of Object . keys ( proxy ) ) {
739+ const normalizedKey = key . toLowerCase ( ) ;
740+ if ( ! normalizedKey . endsWith ( '-opts' ) ) continue ;
741+ if ( key !== normalizedKey ) {
742+ if ( ! hasOwn ( proxy , normalizedKey ) ) {
743+ proxy [ normalizedKey ] = proxy [ key ] ;
744+ }
745+ delete proxy [ key ] ;
746+ }
747+ normalizeOpts ( proxy [ normalizedKey ] ) ;
748+ }
722749 proxy . udp = ! [ false , 0 , '0' , 'false' , 'off' ] . includes (
723750 typeof proxy . udp === 'string' ? proxy . udp . toLowerCase ( ) : proxy . udp ,
724751 ) ;
0 commit comments