Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not include empty aliases in the compressed scopes #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/scopula/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@
(defn- scopes-compress-first
[scopes sorted-aliases]
(let [[alias-name sd] (first (keep (fn [[alias-name ss]]
(when (scopes-subset? ss scopes)
(when (and (scopes-subset? ss scopes)
(seq ss))
(try [alias-name (scope-difference scopes ss)]
(catch Exception _ nil))))
sorted-aliases))]
Expand Down
6 changes: 6 additions & 0 deletions test/scopula/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@
(sut/scopes-compress #{"foo" "bar" "baz" "x"}
{"+admin" #{"foo" "bar"}
"+baz" #{"baz"}})))
(is (= #{"+admin" "+baz" "x"}
(sut/scopes-compress #{"foo" "bar" "baz" "x"}
{"+admin" #{"foo" "bar"}
"+baz" #{"baz"}
"+foo" #{}}))
"Make sure if the alias dictionary have an empty entry, the alias-name will not be included in the compressed-scopes")

(is (= #{"+admin" "+baz" "baz:write" "x"}
(sut/scopes-compress #{"foo" "bar" "baz" "x"}
Expand Down