@@ -1146,14 +1146,13 @@ async function runAuthChecks() {
11461146 assert . ok ( captured , "expected openBrowser to spawn an open command" ) ;
11471147 const expectedCommand =
11481148 process . platform === "win32"
1149- ? "cmd "
1149+ ? "rundll32 "
11501150 : process . platform === "darwin"
11511151 ? "open"
11521152 : "xdg-open" ;
11531153 assert . equal ( captured . command , expectedCommand ) ;
1154- // win32 quotes the URL arg, so match by substring rather than equality.
11551154 assert . ok (
1156- captured . args . some ( ( arg ) => arg . includes ( url ) ) ,
1155+ captured . args . includes ( url ) ,
11571156 "expected the verification URL to be passed to the open command" ,
11581157 ) ;
11591158
@@ -1168,6 +1167,34 @@ async function runAuthChecks() {
11681167 } ;
11691168 assert . doesNotThrow ( ( ) => openBrowser ( url ) ) ;
11701169
1170+ const originalPlatform = process . platform ;
1171+ try {
1172+ Object . defineProperty ( process , "platform" , {
1173+ value : "win32" ,
1174+ } ) ;
1175+
1176+ const windowsUrl =
1177+ "https://cloud.appwrite.io/device?user=a b&next=one|two<three>four^five" ;
1178+ captured = null ;
1179+ childProcess . spawn = ( command , args ) => {
1180+ captured = { command, args } ;
1181+ return {
1182+ on ( ) { } ,
1183+ unref ( ) { } ,
1184+ } ;
1185+ } ;
1186+
1187+ openBrowser ( windowsUrl ) ;
1188+ assert . deepEqual ( captured , {
1189+ command : "rundll32" ,
1190+ args : [ "url.dll,FileProtocolHandler" , windowsUrl ] ,
1191+ } ) ;
1192+ } finally {
1193+ Object . defineProperty ( process , "platform" , {
1194+ value : originalPlatform ,
1195+ } ) ;
1196+ }
1197+
11711198 const listeners = new Map ( ) ;
11721199 const stdin = process . stdin ;
11731200 const originalIsTTY = stdin . isTTY ;
0 commit comments