Added a method to check if an IRI is contained it an array of IRIs
This commit is contained in:
parent
cb9804d29d
commit
a89d5cf5fe
14
iri.go
14
iri.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Reference in a new issue