Skip to content

Commit

Permalink
fix: filter out zero bytes from stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
devbranch-vadym committed Nov 15, 2022
1 parent 305ea25 commit bfa18d9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/wsterm/wsterm.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (w *WebTerm) wsRead() {
}
return
}
os.Stdout.Write(raw)
os.Stdout.Write(filterZeroBytes(raw))
}
}

Expand Down Expand Up @@ -95,3 +95,17 @@ func (w *WebTerm) Run() {
panic(err)
}
}

// filterZeroBytes removes all zero bytes from the given byte array.
func filterZeroBytes(data []byte) []byte {
n := 0

for _, val := range data {
if val != 0 {
data[n] = val
n++
}
}

return data[:n]
}

0 comments on commit bfa18d9

Please sign in to comment.