@@ -12,6 +12,7 @@ const {
1212 isAbsolutePosixPath,
1313 isAbsoluteWindowsPath,
1414} = require ( "../lib/util" ) ;
15+ const { IS_WINDOWS } = require ( "../lib/constants" ) ;
1516const { version } = require ( "../package.json" ) ;
1617
1718const config = {
@@ -120,12 +121,24 @@ script.cgi`);
120121 httpVersion : "1.1" ,
121122 uniqueId : randomUUID ( ) ,
122123 } ;
123- const extraInfo = {
124- filePath : "files/script.cgi" ,
125- fullFilePath : "/home/username/cgi-bin/files/script.cgi" ,
126- env : { ANOTHER_VAR : "another value" } ,
127- trustProxy : false ,
128- } ;
124+ let extraInfo ;
125+
126+ if ( IS_WINDOWS ) {
127+ extraInfo = {
128+ filePath : "files/script.cgi" ,
129+ fullFilePath : "C:\\Users\\username\\cgi-bin\\files\\script.cgi" ,
130+ env : { ANOTHER_VAR : "another value" } ,
131+ trustProxy : false ,
132+ } ;
133+ } else {
134+ extraInfo = {
135+ filePath : "files/script.cgi" ,
136+ fullFilePath : "/home/username/cgi-bin/files/script.cgi" ,
137+ env : { ANOTHER_VAR : "another value" } ,
138+ trustProxy : false ,
139+ } ;
140+ }
141+
129142 let env = createEnvObject ( req , extraInfo ) ;
130143
131144 assert . strictEqual ( env . HTTP_CONTENT_TYPE , "application/json" ) ;
@@ -149,10 +162,19 @@ script.cgi`);
149162 env . SERVER_SOFTWARE ,
150163 `Node.js/${ process . version } (cgi-core/v${ version } )`
151164 ) ;
152- assert . strictEqual (
153- env . SCRIPT_FILENAME ,
154- "/home/username/cgi-bin/files/script.cgi"
155- ) ;
165+
166+ if ( IS_WINDOWS ) {
167+ assert . strictEqual (
168+ env . SCRIPT_FILENAME ,
169+ "C:\\Users\\username\\cgi-bin\\files\\script.cgi"
170+ ) ;
171+ } else {
172+ assert . strictEqual (
173+ env . SCRIPT_FILENAME ,
174+ "/home/username/cgi-bin/files/script.cgi"
175+ ) ;
176+ }
177+
156178 assert . strictEqual ( env . HTTP_HOST , "www.example.org:3002" ) ;
157179 assert . strictEqual ( env . REMOTE_ADDR , "100.100.100.100" ) ;
158180 assert . strictEqual ( env . SERVER_PORT , "3001" ) ;
0 commit comments