@@ -61,13 +61,11 @@ func web() {
6161 })
6262 })
6363 r .GET ("/view/*path" , func (c * gin.Context ) {
64- cPath := strings .Replace (c .Param ("path" ), "/" , "" , 1 )
65- c .File (conf .GoFile + cPath )
64+ c .File (filepath .Join (conf .GoFile , filepath .Clean (c .Param ("path" ))))
6665 })
6766 r .GET ("/download/*path" , func (c * gin.Context ) {
68- cPath := strings .Replace (c .Param ("path" ), "/" , "" , 1 )
69- fileName := filepath .Base (cPath )
70- c .FileAttachment (conf .GoFile + cPath , fileName )
67+ cPath := filepath .Clean (c .Param ("path" ))
68+ c .FileAttachment (filepath .Join (conf .GoFile , cPath ), filepath .Base (cPath ))
7169 })
7270 r .GET ("/d/*path" , func (c * gin.Context ) {
7371 rawPath := c .Param ("path" )
@@ -233,12 +231,8 @@ func main() {
233231 if err == nil {
234232 conf .GoFile = cwd
235233 }
236- } else {
237- conf .GoFile = strings .Replace (conf .GoFile , "./" , "" , 1 )
238- }
239- if conf .GoFile [len (conf .GoFile )- 1 ] != '/' {
240- conf .GoFile = conf .GoFile + "/"
241234 }
235+ conf .GoFile = filepath .Clean (conf .GoFile ) + "/"
242236 fmt .Println ("Run Directory:" + conf .GoFile )
243237 fmt .Println ("goFile Port is " + conf .GoFilePort )
244238 web ()
0 commit comments