fix(json): ensure valid json

This commit is contained in:
yusing
2025-10-26 16:38:08 +08:00
parent 51fc5f017a
commit 51295be463
3 changed files with 4 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package nettypes
import (
urlPkg "net/url"
"github.com/bytedance/sonic"
"github.com/yusing/godoxy/internal/utils"
)
@@ -48,7 +49,7 @@ func (u *URL) MarshalJSON() (text []byte, err error) {
if u == nil {
return []byte("null"), nil
}
return []byte("\"" + u.URL.String() + "\""), nil
return sonic.Marshal(u.URL.String())
}
func (u *URL) Equals(other *URL) bool {