@@ -3,7 +3,7 @@ package com.v2ray.ang.fmt
33import com.v2ray.ang.AppConfig
44import com.v2ray.ang.dto.NetworkType
55import com.v2ray.ang.dto.ProfileItem
6- import com.v2ray.ang.extension.isNotNullEmpty
6+ import com.v2ray.ang.extension.nullIfBlank
77import com.v2ray.ang.handler.MmkvManager
88import com.v2ray.ang.util.HttpUtil
99import com.v2ray.ang.util.Utils
@@ -100,16 +100,16 @@ open class FmtBase {
100100 fun getQueryDic (config : ProfileItem ): HashMap <String , String > {
101101 val dicQuery = HashMap <String , String >()
102102 dicQuery[" security" ] = config.security?.ifEmpty { " none" }.orEmpty()
103- config.sni. let { if (it.isNotNullEmpty()) dicQuery[" sni" ] = it.orEmpty() }
104- config.alpn. let { if (it.isNotNullEmpty()) dicQuery[" alpn" ] = it.orEmpty() }
105- config.echConfigList. let { if (it.isNotNullEmpty()) dicQuery[" ech" ] = it.orEmpty() }
106- config.pinnedCA256. let { if (it.isNotNullEmpty()) dicQuery[" pcs" ] = it.orEmpty() }
107- config.fingerPrint. let { if (it.isNotNullEmpty()) dicQuery[" fp" ] = it.orEmpty() }
108- config.publicKey. let { if (it.isNotNullEmpty()) dicQuery[" pbk" ] = it.orEmpty() }
109- config.shortId. let { if (it.isNotNullEmpty()) dicQuery[" sid" ] = it.orEmpty() }
110- config.spiderX. let { if (it.isNotNullEmpty()) dicQuery[" spx" ] = it.orEmpty() }
111- config.mldsa65Verify. let { if (it.isNotNullEmpty()) dicQuery[" pqv" ] = it.orEmpty() }
112- config.flow. let { if (it.isNotNullEmpty()) dicQuery[" flow" ] = it.orEmpty() }
103+ config.sni?.nullIfBlank()?. let { dicQuery[" sni" ] = it }
104+ config.alpn?.nullIfBlank()?. let { dicQuery[" alpn" ] = it }
105+ config.echConfigList?.nullIfBlank()?. let { dicQuery[" ech" ] = it }
106+ config.pinnedCA256?.nullIfBlank()?. let { dicQuery[" pcs" ] = it }
107+ config.fingerPrint?.nullIfBlank()?. let { dicQuery[" fp" ] = it }
108+ config.publicKey?.nullIfBlank()?. let { dicQuery[" pbk" ] = it }
109+ config.shortId?.nullIfBlank()?. let { dicQuery[" sid" ] = it }
110+ config.spiderX?.nullIfBlank()?. let { dicQuery[" spx" ] = it }
111+ config.mldsa65Verify?.nullIfBlank()?. let { dicQuery[" pqv" ] = it }
112+ config.flow?.nullIfBlank()?. let { dicQuery[" flow" ] = it }
113113 // Add two keys for compatibility: "insecure" and "allowInsecure"
114114 if (config.security == AppConfig .TLS ) {
115115 val insecureFlag = if (config.insecure == true ) " 1" else " 0"
@@ -123,42 +123,42 @@ open class FmtBase {
123123 when (networkType) {
124124 NetworkType .TCP -> {
125125 dicQuery[" headerType" ] = config.headerType?.ifEmpty { " none" }.orEmpty()
126- config.host. let { if (it.isNotNullEmpty()) dicQuery[" host" ] = it.orEmpty() }
126+ config.host?.nullIfBlank()?. let { dicQuery[" host" ] = it }
127127 }
128128
129129 NetworkType .KCP -> {
130130 dicQuery[" headerType" ] = config.headerType?.ifEmpty { " none" }.orEmpty()
131- config.seed. let { if (it.isNotNullEmpty()) dicQuery[" seed" ] = it.orEmpty() }
131+ config.seed?.nullIfBlank()?. let { dicQuery[" seed" ] = it }
132132 }
133133
134134 NetworkType .WS , NetworkType .HTTP_UPGRADE -> {
135- config.host. let { if (it.isNotNullEmpty()) dicQuery[" host" ] = it.orEmpty() }
136- config.path. let { if (it.isNotNullEmpty()) dicQuery[" path" ] = it.orEmpty() }
135+ config.host?.nullIfBlank()?. let { dicQuery[" host" ] = it }
136+ config.path?.nullIfBlank()?. let { dicQuery[" path" ] = it }
137137 }
138138
139139 NetworkType .XHTTP -> {
140- config.host. let { if (it.isNotNullEmpty()) dicQuery[" host" ] = it.orEmpty() }
141- config.path. let { if (it.isNotNullEmpty()) dicQuery[" path" ] = it.orEmpty() }
142- config.xhttpMode. let { if (it.isNotNullEmpty()) dicQuery[" mode" ] = it.orEmpty() }
143- config.xhttpExtra. let { if (it.isNotNullEmpty()) dicQuery[" extra" ] = it.orEmpty() }
140+ config.host?.nullIfBlank()?. let { dicQuery[" host" ] = it }
141+ config.path?.nullIfBlank()?. let { dicQuery[" path" ] = it }
142+ config.xhttpMode?.nullIfBlank()?. let { dicQuery[" mode" ] = it }
143+ config.xhttpExtra?.nullIfBlank()?. let { dicQuery[" extra" ] = it }
144144 }
145145
146146 NetworkType .HTTP , NetworkType .H2 -> {
147147 dicQuery[" type" ] = " http"
148- config.host. let { if (it.isNotNullEmpty()) dicQuery[" host" ] = it.orEmpty() }
149- config.path. let { if (it.isNotNullEmpty()) dicQuery[" path" ] = it.orEmpty() }
148+ config.host?.nullIfBlank()?. let { dicQuery[" host" ] = it }
149+ config.path?.nullIfBlank()?. let { dicQuery[" path" ] = it }
150150 }
151151
152152// NetworkType.QUIC -> {
153153// dicQuery["headerType"] = config.headerType?.ifEmpty { "none" }.orEmpty()
154- // config.quicSecurity. let { if (it.isNotNullEmpty()) dicQuery["quicSecurity"] = it.orEmpty() }
155- // config.quicKey. let { if (it.isNotNullEmpty()) dicQuery["key"] = it.orEmpty() }
154+ // config.quicSecurity?.nullIfBlank()?. let { dicQuery["quicSecurity"] = it }
155+ // config.quicKey?.nullIfBlank()?. let { dicQuery["key"] = it }
156156// }
157157
158158 NetworkType .GRPC -> {
159- config.mode. let { if (it.isNotNullEmpty()) dicQuery[" mode" ] = it.orEmpty() }
160- config.authority. let { if (it.isNotNullEmpty()) dicQuery[" authority" ] = it.orEmpty() }
161- config.serviceName. let { if (it.isNotNullEmpty()) dicQuery[" serviceName" ] = it.orEmpty() }
159+ config.mode?.nullIfBlank()?. let { dicQuery[" mode" ] = it }
160+ config.authority?.nullIfBlank()?. let { dicQuery[" authority" ] = it }
161+ config.serviceName?.nullIfBlank()?. let { dicQuery[" serviceName" ] = it }
162162 }
163163
164164 else -> {}
0 commit comments