File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 66 "encoding/binary"
77 "fmt"
88 "io"
9+ "net/url"
10+ "path/filepath"
911 "runtime/debug"
1012 "strconv"
1113 "strings"
@@ -668,6 +670,18 @@ func (s *Server) DirectoryExists(path string) bool {
668670 return s .fs .DirectoryExists (path )
669671}
670672
673+ func fileURLToPath (rawURL string ) (string , error ) {
674+ u , err := url .Parse (rawURL )
675+ if err != nil {
676+ return "" , err
677+ }
678+ if u .Scheme != "file" {
679+ return "" , fmt .Errorf ("not a file URL: %s" , u .Scheme )
680+ }
681+ // On Windows, url.Path starts with "/", e.g. /C:/path/to/file
682+ return filepath .FromSlash (u .Path ), nil
683+ }
684+
671685// FileExists implements vfs.FS.
672686func (s * Server ) FileExists (path string ) bool {
673687 if s .enabledCallbacks & CallbackFileExists != 0 {
@@ -679,6 +693,13 @@ func (s *Server) FileExists(path string) bool {
679693 return string (result ) == "true"
680694 }
681695 }
696+ if strings .HasPrefix (path , "file://" ) {
697+ path , err := fileURLToPath (path )
698+ if err != nil {
699+ panic (err )
700+ }
701+ return s .fs .FileExists (path )
702+ }
682703 return s .fs .FileExists (path )
683704}
684705
You can’t perform that action at this time.
0 commit comments