Skip to content

Commit d7ca8db

Browse files
committed
fix(serverHandler): reserve per-user permission from parent alias
1 parent 9213adf commit d7ca8db

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/serverHandler/pathValues.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ func (list pathValuesList[T]) mergePrefixMatched(mergeWith []T, matchPrefix pref
3636
}
3737
}
3838

39-
func (list pathValuesList[T]) filterSuccessor(includeSelf bool, matchPrefix prefixFilter, refPath string) pathValuesList[T] {
39+
func (list pathValuesList[T]) filterSuccessor(includeSelfPredecessor bool, matchPrefix prefixFilter, refPath string) pathValuesList[T] {
4040
var result pathValuesList[T]
4141

4242
for i := range list {
43-
if !includeSelf && len(list[i].path) == len(refPath) {
44-
continue
45-
}
46-
if matchPrefix(list[i].path, refPath) {
43+
if len(list[i].path) <= len(refPath) {
44+
if includeSelfPredecessor && matchPrefix(refPath, list[i].path) {
45+
result = append(result, list[i])
46+
}
47+
} else if matchPrefix(list[i].path, refPath) {
4748
result = append(result, list[i])
4849
}
4950
}

src/serverHandler/pathValues_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestPathInts(t *testing.T) {
3232
t.Error(successors)
3333
}
3434
successors = ps.filterSuccessor(true, util.HasUrlPrefixDir, "/a/b")
35-
if len(successors) != 2 || successors[0].path != "/a/b" || successors[1].path != "/a/b/c" {
35+
if len(successors) != 3 || successors[0].path != "/a" || successors[1].path != "/a/b" || successors[2].path != "/a/b/c" {
3636
t.Error(successors)
3737
}
3838
}
@@ -64,7 +64,7 @@ func TestPathStrings(t *testing.T) {
6464
t.Error(successors)
6565
}
6666
successors = ps.filterSuccessor(true, util.HasUrlPrefixDir, "/a/b")
67-
if len(successors) != 2 || successors[0].path != "/a/b" || successors[1].path != "/a/b/c" {
67+
if len(successors) != 3 || successors[0].path != "/a" || successors[1].path != "/a/b" || successors[2].path != "/a/b/c" {
6868
t.Error(successors)
6969
}
7070
}
@@ -96,7 +96,7 @@ func TestPathHeaders(t *testing.T) {
9696
t.Error(successors)
9797
}
9898
successors = ps.filterSuccessor(true, util.HasUrlPrefixDir, "/a/b")
99-
if len(successors) != 2 || successors[0].path != "/a/b" || successors[1].path != "/a/b/c" {
99+
if len(successors) != 3 || successors[0].path != "/a" || successors[1].path != "/a/b" || successors[2].path != "/a/b/c" {
100100
t.Error(successors)
101101
}
102102
}

0 commit comments

Comments
 (0)