Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.py #711

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/711.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[yurj] fix use of relative urls in replace_link_variables_by_paths and in the Link view
4 changes: 1 addition & 3 deletions plone/app/contenttypes/browser/link_redirect_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion plone/app/contenttypes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down