Skip to content

Commit

Permalink
Improve RESOLVEUID_RE regexp to catch also paths generated by Link co…
Browse files Browse the repository at this point in the history
…ntent-types (#1700)

* Improve regexp to catch also paths generated by Link content-types

* add changelog
  • Loading branch information
cekk committed Sep 3, 2023
1 parent b58560e commit 36e67bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/1699.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve RESOLVEUID_RE regexp to catch also paths generated by Link content-types. @cekk
2 changes: 1 addition & 1 deletion src/plone/restapi/serializer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re


RESOLVEUID_RE = re.compile("^[./]*resolve[Uu]id/([^/]*)/?(.*)$")
RESOLVEUID_RE = re.compile("^(?:|.*/)resolve[Uu]id/([^/]*)/?(.*)$")


def resolve_uid(path):
Expand Down
7 changes: 6 additions & 1 deletion src/plone/restapi/tests/test_resolveuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class TestBlocksResolveUIDFunctional(TestCase):

layer = PLONE_RESTAPI_BLOCKS_FUNCTIONAL_TESTING

def setUp(self):
Expand Down Expand Up @@ -698,3 +697,9 @@ def test_resolveuid_with_primary_field_url_keeps_suffix(self):
]["url"],
self.doc2.absolute_url() + "/view",
)

def test_resolveuid_handle_link_style_formats(self):
uid = IUUID(self.doc2)
blocks = {"aaa": {"@type": "foo", "url": f"/plone/resolveuid/{uid}"}}
value = self.serialize("blocks", blocks)
self.assertEqual(value["aaa"]["url"], self.doc2.absolute_url())

0 comments on commit 36e67bd

Please sign in to comment.