@@ -3,7 +3,7 @@ import { promises as fs } from "fs"
33import * as net from "net"
44import * as os from "os"
55import * 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"
77import { tmpdir } from "../../src/node/constants"
88import { paths } from "../../src/node/util"
99
@@ -337,6 +337,18 @@ describe("parser", () => {
337337 "proxy-domain" : [ "coder.com" , "coder.org" ] ,
338338 } )
339339 } )
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+ } )
340352} )
341353
342354describe ( "cli" , ( ) => {
@@ -411,3 +423,28 @@ describe("cli", () => {
411423 expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
412424 } )
413425} )
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