Skip to content

Commit f339829

Browse files
committed
Allow potential compilation into wasm
The modified file was the only thing in boxo erroring when attempting to build a wasm target
1 parent c7a95fc commit f339829

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ The following emojis are used to highlight certain changes:
2424

2525
### Fixed
2626

27+
- Improvements to support WASM builds
2728
- `gateway`: Fixed suffix range-requests and updated tests to [gateway-conformance v0.8](https://github.com/ipfs/gateway-conformance/releases/tag/v0.8.0) [#922](https://github.com/ipfs/boxo/pull/922)
2829

30+
2931
### Security
3032

3133

files/filewriter_js.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build js
2+
3+
package files
4+
5+
import (
6+
"os"
7+
"strings"
8+
)
9+
10+
var invalidChars = `/` + "\x00"
11+
12+
func isValidFilename(filename string) bool {
13+
return !strings.ContainsAny(filename, invalidChars)
14+
}
15+
16+
func createNewFile(path string) (*os.File, error) {
17+
return os.OpenFile(path, os.O_EXCL|os.O_CREATE|os.O_WRONLY, 0o666)
18+
}

files/filewriter_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build darwin || linux || netbsd || openbsd || freebsd || dragonfly || js || wasip1
1+
//go:build darwin || linux || netbsd || openbsd || freebsd || dragonfly
22

33
package files
44

0 commit comments

Comments
 (0)