Added URL() method to the IRI type
This commit is contained in:
parent
5829d05992
commit
a8cd8b42ca
6
iri.go
6
iri.go
|
@ -1,6 +1,7 @@
|
|||
package activitystreams
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -19,6 +20,11 @@ func (i IRI) GetLink() IRI {
|
|||
return i
|
||||
}
|
||||
|
||||
// URL
|
||||
func (i IRI) URL() (*url.URL, error) {
|
||||
return url.Parse(i.String())
|
||||
}
|
||||
|
||||
// UnmarshalJSON
|
||||
func (i *IRI) UnmarshalJSON(s []byte) error {
|
||||
*i = IRI(strings.Trim(string(s), "\""))
|
||||
|
|
|
@ -62,3 +62,7 @@ func TestIRI_UnmarshalJSON(t *testing.T) {
|
|||
func TestFlattenToIRI(t *testing.T) {
|
||||
t.Skipf("TODO")
|
||||
}
|
||||
|
||||
func TestIRI_URL(t *testing.T) {
|
||||
t.Skipf("TODO")
|
||||
}
|
||||
|
|
Reference in a new issue