Merge pull request 'attr/parseScope()' (#439) from parseScope into master
Reviewed-on: #439 Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
commit
a27fd47755
|
@ -1,5 +1,10 @@
|
||||||
package attr
|
package attr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.openprivacy.ca/openprivacy/log"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Scope model for peer attributes and requests
|
Scope model for peer attributes and requests
|
||||||
|
|
||||||
|
@ -78,3 +83,16 @@ func (scope Scope) IsPublic() bool {
|
||||||
func (scope Scope) IsConversation() bool {
|
func (scope Scope) IsConversation() bool {
|
||||||
return scope == ConversationScope
|
return scope == ConversationScope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseScope takes in an untyped string and returns an explicit Scope along with the rest of the untyped path
|
||||||
|
func ParseScope(path string) (Scope, string) {
|
||||||
|
parts := strings.SplitN(path, Separator, 3)
|
||||||
|
|
||||||
|
log.Debugf("parsed scope: %v %v", parts, path)
|
||||||
|
|
||||||
|
if len(parts) != 3 {
|
||||||
|
return UnknownScope, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return IntoScope(parts[0]), parts[1] + Separator + parts[2]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue