Skip to content

Commit 30f527c

Browse files
committed
fix: always set currentBaseURL and don't do checks on WASM
currentBaseURL was not always set as it should've been. Also, since starting from ac7642a we try to properly check local files when we should, disable them on WASM because likely there's no actual filesystem in that case.
1 parent e709259 commit 30f527c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

parser.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ func (p *Parser) ParseStream(in io.Reader) (PublicCode, error) {
238238
p.currentBaseURL = &u
239239
p.currentBaseURL.Path = path.Dir(p.fileURL.Path)
240240
}
241+
} else {
242+
u := *p.baseURL
243+
244+
p.currentBaseURL = &u
241245
}
242246

243247
// Still no base URL: we parsed from a stream, try to use the publiccode.yml's `url` field

validations.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ func toCodeHostingURL(file string, baseURL *url.URL) url.URL {
117117

118118
// fileExists returns true if the file resource exists.
119119
func (p *Parser) fileExists(u url.URL, network bool) (bool, error) {
120+
// Don't check if we are running in WASM because there's no stat(2) there
121+
if runtime.GOARCH == "wasm" {
122+
return true, nil
123+
}
124+
120125
// If we have an absolute local path, perform validation on it, otherwise do it
121126
// on the remote URL if any. If none are available, validation is skipped.
122127
if u.Scheme == "file" {

0 commit comments

Comments
 (0)