Added go fmt functionality for IRI to escape url query

This commit is contained in:
mariusor 2022-05-24 15:47:36 +02:00
parent 7ed0d30e7c
commit 7c011e3a74
No known key found for this signature in database
GPG key ID: DBF5E47F5DBC4D21

10
iri.go
View file

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/gob"
"fmt"
"io"
"net/url"
"path"
"strings"
@ -36,6 +37,15 @@ type (
IRIs []IRI
)
func (i IRI) Format(s fmt.State, verb rune) {
switch verb {
case 's', 'v':
u, _ := i.URL()
u.RawQuery, _ = url.QueryUnescape(u.RawQuery)
io.WriteString(s, u.String())
}
}
// String returns the String value of the IRI object
func (i IRI) String() string {
return string(i)