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