Skip to content

Commit

Permalink
Fix santhosh-tekuri#58: Do not call filepath funcs for WASM
Browse files Browse the repository at this point in the history
  • Loading branch information
bserdar committed Mar 1, 2022
1 parent 2ee8058 commit 2dbf9de
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ func toAbs(s string) (string, error) {
return s, nil
}

// Workaround for WASM: relative filepaths cannot be resolved in
// WASM ebcause not all filesystem functions are implemented.
if runtime.GOOS == "js" {
if !strings.HasPrefix(s, "file://") && s[0] != '/' {
s = "file://" + s
}
return s, nil
}

// s is filepath
if s, err = filepath.Abs(s); err != nil {
return "", err
Expand Down

0 comments on commit 2dbf9de

Please sign in to comment.