File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
main/kotlin/taboolib/common5 Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ package taboolib.common5
3939 * @since 2020/11/22 2:51 下午
4040 */
4141@Suppress(" ReplaceSubstringWithDropLast" , " ReplaceSubstringWithTake" )
42- class Demand (val source : String ) {
42+ class Demand (source : String ) {
43+
44+ val source = source.trim()
4345
4446 lateinit var namespace: String
4547
@@ -112,6 +114,9 @@ class Demand(val source: String) {
112114 setKey : (String ) -> Unit ,
113115 setState : (ParseState ) -> Unit
114116 ) {
117+ if (arg.isEmpty()) {
118+ return
119+ }
115120 val ch = arg[0 ]
116121 when {
117122 // 处理标签
Original file line number Diff line number Diff line change @@ -226,6 +226,12 @@ class DemandTest {
226226 // 性能断言:平均每次解析应该少于1ms(可以根据实际情况调整)
227227 assertTrue(avgTime < 1.0 , " 平均解析时间过长: ${avgTime} ms" )
228228 }
229+
230+ @Test
231+ fun testSpace () {
232+ Demand (" command arg1 arg2 " )
233+ Demand (" command arg1 arg2 -key1 value1 -key2 \" value with spaces\" --tag1 --tag2 " )
234+ }
229235}
230236
231237/* *
You can’t perform that action at this time.
0 commit comments