Added a method to check if an IRI is contained it an array of IRIs

This commit is contained in:
Marius Orcsik 2019-08-17 15:17:10 +02:00
parent cb9804d29d
commit a89d5cf5fe
2 changed files with 18 additions and 0 deletions

14
iri.go
View file

@ -8,6 +8,7 @@ import (
type (
// IRI is a Internationalized Resource Identifiers (IRIs) RFC3987
IRI string
IRIs []IRI
)
// String returns the String value of the IRI object
@ -59,3 +60,16 @@ func FlattenToIRI(it Item) Item {
}
return it
}
// Contains verifies if IRIs array contains the received one
func(i IRIs) Contains(r IRI) bool {
if len(i) == 0 {
return true
}
for _, iri := range i {
if strings.ToLower(r.String()) == strings.ToLower(iri.String()) {
return true
}
}
return false
}

View file

@ -66,3 +66,7 @@ func TestFlattenToIRI(t *testing.T) {
func TestIRI_URL(t *testing.T) {
t.Skipf("TODO")
}
func TestIRIs_Contains(t *testing.T) {
t.Skipf("TODO")
}