@@ -3,7 +3,7 @@ import { promises as fs } from "fs"
3
3
import * as net from "net"
4
4
import * as os from "os"
5
5
import * as path from "path"
6
- import { Args , parse , setDefaults , shouldOpenInExistingInstance } from "../../src/node/cli"
6
+ import { Args , parse , setDefaults , shouldOpenInExistingInstance , splitOnFirstEquals } from "../../src/node/cli"
7
7
import { tmpdir } from "../../src/node/constants"
8
8
import { paths } from "../../src/node/util"
9
9
@@ -337,6 +337,18 @@ describe("parser", () => {
337
337
"proxy-domain" : [ "coder.com" , "coder.org" ] ,
338
338
} )
339
339
} )
340
+ it ( "should allow '=,$/' in strings" , async ( ) => {
341
+ const args = parse ( [
342
+ "--enable-proposed-api" ,
343
+ "$argon2i$v=19$m=4096,t=3,p=1$0qr/o+0t00hsbjfqcksfdq$ofcm4rl6o+b7oxpua4qlxubypbbpsf+8l531u7p9hyy" ,
344
+ ] )
345
+ expect ( args ) . toEqual ( {
346
+ _ : [ ] ,
347
+ "enable-proposed-api" : [
348
+ "$argon2i$v=19$m=4096,t=3,p=1$0qr/o+0t00hsbjfqcksfdq$ofcm4rl6o+b7oxpua4qlxubypbbpsf+8l531u7p9hyy" ,
349
+ ] ,
350
+ } )
351
+ } )
340
352
} )
341
353
342
354
describe ( "cli" , ( ) => {
@@ -411,3 +423,28 @@ describe("cli", () => {
411
423
expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
412
424
} )
413
425
} )
426
+
427
+ describe ( "splitOnFirstEquals" , ( ) => {
428
+ it ( "should split on the first equals" , ( ) => {
429
+ const testStr = "--enabled-proposed-api=test=value"
430
+ const actual = splitOnFirstEquals ( testStr )
431
+ const expected = [ "--enabled-proposed-api" , "test=value" ]
432
+ expect ( actual ) . toEqual ( expect . arrayContaining ( expected ) )
433
+ } )
434
+ it ( "should split on first equals regardless of multiple equals signs" , ( ) => {
435
+ const testStr =
436
+ "--hashed-password=$argon2i$v=19$m=4096,t=3,p=1$0qR/o+0t00hsbJFQCKSfdQ$oFcM4rL6o+B7oxpuA4qlXubypbBPsf+8L531U7P9HYY"
437
+ const actual = splitOnFirstEquals ( testStr )
438
+ const expected = [
439
+ "--hashed-password" ,
440
+ "$argon2i$v=19$m=4096,t=3,p=1$0qR/o+0t00hsbJFQCKSfdQ$oFcM4rL6o+B7oxpuA4qlXubypbBPsf+8L531U7P9HYY" ,
441
+ ]
442
+ expect ( actual ) . toEqual ( expect . arrayContaining ( expected ) )
443
+ } )
444
+ it ( "should always return two elements" , ( ) => {
445
+ const testStr = ""
446
+ const actual = splitOnFirstEquals ( testStr )
447
+ const expected = [ "" , "" ]
448
+ expect ( actual ) . toEqual ( expect . arrayContaining ( expected ) )
449
+ } )
450
+ } )
0 commit comments