Return source if there are no matches in Replace* functions

This commit is contained in:
Elara 2022-05-21 11:56:35 -07:00
parent 06785bac1a
commit 4630bc96b4

View File

@ -378,7 +378,7 @@ func (r *Regexp) ReplaceAll(src, repl []byte) []byte {
panic(err)
}
if len(matches) == 0 {
return nil
return src
}
out := make([]byte, len(src))
@ -423,7 +423,7 @@ func (r *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte {
panic(err)
}
if len(matches) == 0 {
return nil
return src
}
out := make([]byte, len(src))
@ -447,7 +447,7 @@ func (r *Regexp) ReplaceAllLiteral(src, repl []byte) []byte {
panic(err)
}
if len(matches) == 0 {
return nil
return src
}
out := make([]byte, len(src))