Skip to content

Commit

Permalink
Handle root path
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Mar 25, 2024
1 parent bb09612 commit 90abe75
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/collective/volto/stickyblocks/restapi/sticky_blocks/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ def __call__(self, expand=False):

def get_sticky_blocks(self):
"""Get sticky blocks for the current context"""
from functools import cmp_to_key

context_path = "/".join(self.context.getPhysicalPath())
context_path = "/" + "/".join(self.context.getPhysicalPath()[2:])

for item in self.get_config():
if item["rootPath"] == context_path:
return item
matches = sorted(
[i for i in self.get_config() if context_path.startswith(i["rootPath"])],
key=cmp_to_key(lambda a, b: len(a) > len(b)),
)

return matches and matches[-1] or []

def get_config(self):
return json.loads(
Expand Down

0 comments on commit 90abe75

Please sign in to comment.