From 0d372001099745956c6389f50f6ed3ecbf31ce87 Mon Sep 17 00:00:00 2001 From: Benoit Suttor Date: Wed, 22 Apr 2020 17:38:47 +0200 Subject: [PATCH 1/3] Improve _replace_variable_by_path Return an url and not a path --- plone/app/contenttypes/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/app/contenttypes/utils.py b/plone/app/contenttypes/utils.py index 262fac814..b18e8f64f 100644 --- a/plone/app/contenttypes/utils.py +++ b/plone/app/contenttypes/utils.py @@ -40,5 +40,5 @@ def replace_link_variables_by_paths(context, url): def _replace_variable_by_path(url, variable, obj): - path = '/'.join(obj.getPhysicalPath()) + path = obj.absolute_url() return url.replace(variable, path) From 0b4df0f5b62090807162b1c9a2ff6608a600a556 Mon Sep 17 00:00:00 2001 From: Benoit Suttor Date: Wed, 22 Apr 2020 17:50:40 +0200 Subject: [PATCH 2/3] Add changelog --- news/550.bugfix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 news/550.bugfix diff --git a/news/550.bugfix b/news/550.bugfix new file mode 100644 index 000000000..34a5d69c6 --- /dev/null +++ b/news/550.bugfix @@ -0,0 +1,2 @@ +Fix "replace link variable by path" indexer to return an url and not a path. +[bsuttor] From dd4865a789117ac27f014349fa48ef1ce97fee48 Mon Sep 17 00:00:00 2001 From: Benoit Suttor Date: Wed, 22 Apr 2020 18:48:29 +0200 Subject: [PATCH 3/3] Update tests --- plone/app/contenttypes/tests/test_indexes.py | 2 +- plone/app/contenttypes/tests/test_link.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plone/app/contenttypes/tests/test_indexes.py b/plone/app/contenttypes/tests/test_indexes.py index e10eef5df..77b7218db 100644 --- a/plone/app/contenttypes/tests/test_indexes.py +++ b/plone/app/contenttypes/tests/test_indexes.py @@ -356,7 +356,7 @@ def test_get_remote_url_in_metadata_variables_replaced(self): )) self.assertEqual( brains[0].getRemoteUrl, - '/plone/my-item' + 'http://nohost/plone/my-item' ) def test_getobjsize_image(self): diff --git a/plone/app/contenttypes/tests/test_link.py b/plone/app/contenttypes/tests/test_link.py index 5f729ba21..57a182d8f 100644 --- a/plone/app/contenttypes/tests/test_link.py +++ b/plone/app/contenttypes/tests/test_link.py @@ -373,9 +373,9 @@ def test_var_replacement_in_view(self): ) self.link.remoteUrl = '${portal_url}' - self.assertEqual(view.url(), '/plone') + self.assertEqual(view.url(), 'http://nohost/plone') self.assertEqual(view.absolute_target_url(), 'http://nohost/plone') self.link.remoteUrl = '${navigation_root_url}' - self.assertEqual(view.url(), '/plone') + self.assertEqual(view.url(), 'http://nohost/plone') self.assertEqual(view.absolute_target_url(), 'http://nohost/plone')