add unit-tests (#136)
All checks were successful
test / test (push) Successful in 3m20s

This commit is contained in:
2025-05-14 01:50:09 +05:00
committed by GitHub
parent 0f33dbcfaf
commit b42eafe69f
5 changed files with 127 additions and 3 deletions

6
xml.go
View File

@@ -134,9 +134,9 @@ func newReader(b []byte) io.Reader {
}
var (
srcP = []byte(`version="1.1"`)
srcP = []byte(`<?xml version="1.1"`)
srcL = len(srcP)
dstP = []byte(`version="1.0"`)
dstP = []byte(`<?xml version="1.0"`)
)
func (r *reader) Read(b []byte) (n int, err error) {
@@ -146,7 +146,7 @@ func (r *reader) Read(b []byte) (n int, err error) {
r.prevRune = -1
n = copy(b, r.s[r.i:])
if !r.skip {
if idx := bytes.Index(b, srcP); idx > 0 {
if idx := bytes.Index(b, srcP); idx >= 0 {
copy(b[idx:idx+srcL], dstP)
r.skip = true
}