Added URL() method to the IRI type

This commit is contained in:
Marius Orcsik 2019-06-02 14:59:04 +02:00
parent 5829d05992
commit a8cd8b42ca
No known key found for this signature in database
GPG key ID: 889CE8E4FB2D877A
2 changed files with 10 additions and 0 deletions

6
iri.go
View file

@ -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), "\""))

View file

@ -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")
}