Skip to content

Commit

Permalink
feat: the URN struct can eventually point to a SCIM struct instance now
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
  • Loading branch information
leodido committed Jan 26, 2024
1 parent b37cf87 commit e96adc2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions urn.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type URN struct {
ID string // Namespace identifier (NID)
SS string // Namespace specific string (NSS)
norm string // Normalized namespace specific string
kind Kind
scim *SCIM
}

// Normalize turns the receiving URN into its norm version.
Expand Down Expand Up @@ -56,9 +58,9 @@ func (u *URN) String() string {
return res
}

// Parse is responsible to create an URN instance from a byte array matching the correct URN syntax.
func Parse(u []byte) (*URN, bool) {
urn, err := NewMachine().Parse(u)
// Parse is responsible to create an URN instance from a byte array matching the correct URN syntax (RFC 2141).
func Parse(u []byte, options ...Option) (*URN, bool) {
urn, err := NewMachine(options...).Parse(u)

Check failure on line 63 in urn.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.20)

cannot use ... in call to non-variadic NewMachine

Check failure on line 63 in urn.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.21)

cannot use ... in call to non-variadic NewMachine
if err != nil {
return nil, false
}
Expand All @@ -84,3 +86,15 @@ func (u *URN) UnmarshalJSON(bytes []byte) error {
}
return nil
}

func (u *URN) IsSCIM() bool {
return u.kind == RFC7643
}

func (u *URN) SCIM() *SCIM {
if !u.IsSCIM() {
return nil
}

return u.scim
}

0 comments on commit e96adc2

Please sign in to comment.