diff --git a/news/711.bugfix b/news/711.bugfix new file mode 100644 index 000000000..d3051a5f0 --- /dev/null +++ b/news/711.bugfix @@ -0,0 +1 @@ +[yurj] fix use of relative urls in replace_link_variables_by_paths and in the Link view diff --git a/plone/app/contenttypes/browser/link_redirect_view.py b/plone/app/contenttypes/browser/link_redirect_view.py index 645ee5b4b..b4250df7d 100644 --- a/plone/app/contenttypes/browser/link_redirect_view.py +++ b/plone/app/contenttypes/browser/link_redirect_view.py @@ -111,9 +111,7 @@ def display_link(self): obj = uuidToObject(uid) if obj: title = obj.Title() - meta = "/".join(obj.getPhysicalPath()[2:]) - if not meta.startswith("/"): - meta = "/" + meta + meta = obj.absolute_url_path() return { "title": title, "meta": meta, diff --git a/plone/app/contenttypes/utils.py b/plone/app/contenttypes/utils.py index b4c89a3c5..1e4ccde0f 100644 --- a/plone/app/contenttypes/utils.py +++ b/plone/app/contenttypes/utils.py @@ -48,7 +48,11 @@ def replace_link_variables_by_paths(context, url): def _replace_variable_by_path(url, variable, obj): - path = "/".join(obj.getPhysicalPath()) + path = obj.absolute_url_path() + # if path is '/' (didn't happen with getPhysicalPath), avoid + # ${navigation_root_url}/sitemap -> //sitemap + if path == "/": + path = "" return url.replace(variable, path)