@@ -10,7 +10,6 @@ import (
10
10
"fmt"
11
11
"io"
12
12
"io/fs"
13
- "io/ioutil"
14
13
"log"
15
14
"math/big"
16
15
"net"
@@ -126,9 +125,10 @@ func GetLocalIP() string {
126
125
127
126
// DecodeForm performs URL query unescaping on encoded form data to make parsing
128
127
// easier. Remaining encoded strings are:
129
- // % -> %25
130
- // & -> %26
131
- // = -> %3D
128
+ //
129
+ // % -> %25
130
+ // & -> %26
131
+ // = -> %3D
132
132
//
133
133
// If "%" is not encoded first in the pre-encoding step, then it will encode the
134
134
// percent signs from the encoding of & and = in addition to real percent signs,
@@ -183,7 +183,7 @@ func IsWSL() bool {
183
183
}
184
184
185
185
for _ , filename := range filesToCheck {
186
- raw , err := ioutil .ReadFile (filename )
186
+ raw , err := os .ReadFile (filename )
187
187
if err == nil && r .Match (raw ) {
188
188
return true
189
189
}
@@ -267,9 +267,17 @@ func GetShebang(path string) string {
267
267
return strings .TrimSuffix (strings .TrimPrefix (string (result ), "#!" ), "\r " )
268
268
}
269
269
270
- // GetFormAsArguments converts a parsed form such that the variable name=value
271
- // becomes the following. Names are always preceded by two dashes "--".
272
- // []string{"--name", "value"}
270
+ // GetFormAsArguments converts a parsed form such that the variables:
271
+ //
272
+ // name=value
273
+ // n=val
274
+ // noval=
275
+ //
276
+ // become the following. Multi-character names are preceded by two dashes "--"
277
+ // while single-character names are preceded by one dash "-". Names with no
278
+ // value are passed literally with no preceding dashes.
279
+ //
280
+ // []string{"--name", "value", "-n", "val", "noval"}
273
281
//
274
282
// No guarantees are made about the order of the variables in the resulting
275
283
// slice, except that every name directly precedes its respective value.
@@ -279,9 +287,14 @@ func GetFormAsArguments(form url.Values) []string {
279
287
if k != "" {
280
288
for _ , v := range vs {
281
289
if v != "" {
282
- result = append (result , "--" + k , v )
290
+ switch len (k ) {
291
+ case 1 :
292
+ result = append (result , "-" + k , v )
293
+ default :
294
+ result = append (result , "--" + k , v )
295
+ }
283
296
} else {
284
- result = append (result , "--" + k )
297
+ result = append (result , k )
285
298
}
286
299
}
287
300
} else {
@@ -744,7 +757,7 @@ https://github.com/jstrieb/quickserv`)
744
757
localIP := GetLocalIP ()
745
758
logger .Println ("Starting a server..." )
746
759
fmt .Printf ("Visit http://%v:%v to access the server from the local network.\n " , localIP , port )
747
- fmt .Println ("Press Control + C or close this window to stop the server.\n " )
760
+ fmt .Print ("Press Control + C or close this window to stop the server.\n \n " )
748
761
749
762
// Build a handler that decides whether to serve static files or dynamically
750
763
// execute them
0 commit comments