diff --git a/js/initcontext.go b/js/initcontext.go index 52e10cc9809..82ba3fd560a 100644 --- a/js/initcontext.go +++ b/js/initcontext.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "net/url" - "path/filepath" "github.com/dop251/goja" "github.com/sirupsen/logrus" @@ -20,20 +19,7 @@ const cantBeUsedOutsideInitContextMsg = `the "%s" function is only available in // contents of a file. If the second argument is "b" it returns an ArrayBuffer // instance, otherwise a string representation. func openImpl(rt *goja.Runtime, fs fsext.Fs, basePWD *url.URL, filename string, args ...string) (goja.Value, error) { - // Here IsAbs should be enough but unfortunately it doesn't handle absolute paths starting from - // the current drive on windows like `\users\noname\...`. Also it makes it more easy to test and - // will probably be need for archive execution under windows if always consider '/...' as an - // absolute path. - if filename[0] != '/' && filename[0] != '\\' && !filepath.IsAbs(filename) { - filename = filepath.Join(basePWD.Path, filename) - } - filename = filepath.Clean(filename) - - if filename[0:1] != fsext.FilePathSeparator { - filename = fsext.FilePathSeparator + filename - } - - data, err := readFile(fs, filename) + data, err := readFile(fs, fsext.Abs(basePWD.Path, filename)) if err != nil { return nil, err }