Handle absolute_url when 'context' argument is a string
authorThierry Florac <thierry.florac@onf.fr>
Tue, 16 Jan 2018 17:48:46 +0100
changeset 127 0fcad7725bdc
parent 126 e2aeba0dd99c
child 128 5b80ba4fba8e
Handle absolute_url when 'context' argument is a string
src/pyams_utils/url.py
--- a/src/pyams_utils/url.py	Sun Jan 14 15:01:29 2018 +0100
+++ b/src/pyams_utils/url.py	Tue Jan 16 17:48:46 2018 +0100
@@ -38,6 +38,11 @@
     add checks to remove some double slashes, and add control on view name when it begins with a '#'
     character which is used by MyAMS.js framework.
     """
+
+    # if we pass a string to absolute_url(), argument is returned as-is!
+    if isinstance(context, str):
+        return context
+
     # if we have several parents without name in the lineage, the resource URL contains a double slash
     # which generates "NotFound" exceptions; so we replace it with a single slash...
     result = resource_url(context, request).replace('//', '/').replace(':/', '://')