Added go fmt functionality for IRI to escape url query
This commit is contained in:
parent
7ed0d30e7c
commit
7c011e3a74
10
iri.go
10
iri.go
|
@ -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)
|
||||
|
|
Reference in a new issue