fix: Implement database serialization for gemini URL type

This commit is contained in:
2024-11-11 16:14:59 +02:00
parent 8b341d2ac6
commit a19f157c80

View File

@@ -1,6 +1,7 @@
package gemini package gemini
import ( import (
"database/sql/driver"
"fmt" "fmt"
"net/url" "net/url"
"strconv" "strconv"
@@ -35,7 +36,14 @@ func (u *URL) Scan(value interface{}) error {
func (u *URL) String() string { func (u *URL) String() string {
return u.Full return u.Full
// return fmt.Sprintf("%s://%s:%d%s", u.Protocol, u.Hostname, u.Port, u.Path) }
// Value implements the driver.Valuer interface
func (u URL) Value() (driver.Value, error) {
if u.Full == "" {
return nil, nil
}
return u.Full, nil
} }
func ParseURL(input string, descr string) (*URL, error) { func ParseURL(input string, descr string) (*URL, error) {