@@ -30,8 +30,9 @@ function SurgeRuleSet() {
3030 const type = 'SINGLE' ;
3131 const func = ( rule ) => {
3232 let output = `${ rule . type } ,${ rule . content } ` ;
33- if ( rule . type === 'IP-CIDR' || rule . type === 'IP-CIDR6' ) {
34- output += rule . options ? `,${ rule . options } ` : '' ;
33+ if ( [ 'IP-CIDR' , 'IP-CIDR6' ] . includes ( rule . type ) ) {
34+ output +=
35+ rule . options ?. length > 0 ? `,${ rule . options . join ( ',' ) } ` : '' ;
3536 }
3637 return output ;
3738 } ;
@@ -44,6 +45,12 @@ function LoonRules() {
4445 // skip unsupported rules
4546 const UNSUPPORTED = [ 'DEST-PORT' , 'SRC-IP' , 'IN-PORT' , 'PROTOCOL' ] ;
4647 if ( UNSUPPORTED . indexOf ( rule . type ) !== - 1 ) return null ;
48+ if ( [ 'IP-CIDR' , 'IP-CIDR6' ] . includes ( rule . type ) && rule . options ) {
49+ // Loon only supports the no-resolve option
50+ rule . options = rule . options . filter ( ( option ) =>
51+ [ 'no-resolve' ] . includes ( option ) ,
52+ ) ;
53+ }
4754 return SurgeRuleSet ( ) . func ( rule ) ;
4855 } ;
4956 return { type, func } ;
@@ -62,8 +69,17 @@ function ClashRuleProvider() {
6269 let output = `${ TRANSFORM [ rule . type ] || rule . type } ,${
6370 rule . content
6471 } `;
65- if ( rule . type === 'IP-CIDR' || rule . type === 'IP-CIDR6' ) {
66- output += rule . options ? `,${ rule . options } ` : '' ;
72+ if ( [ 'IP-CIDR' , 'IP-CIDR6' ] . includes ( rule . type ) ) {
73+ if ( rule . options ) {
74+ // Clash only supports the no-resolve option
75+ rule . options = rule . options . filter ( ( option ) =>
76+ [ 'no-resolve' ] . includes ( option ) ,
77+ ) ;
78+ }
79+ output +=
80+ rule . options ?. length > 0
81+ ? `,${ rule . options . join ( ',' ) } `
82+ : '' ;
6783 }
6884 return output ;
6985 } ) ,
0 commit comments