diff MoinMoin/wikiutil.py @ 2704:c6b5c2d813b6

fix AbsPageName(), add tests for it
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 21 Aug 2007 15:45:24 +0200
parents 2e6227a50d27
children 4a4d84273ae1 7bfe80df6772
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Tue Aug 21 13:09:07 2007 +0200
+++ b/MoinMoin/wikiutil.py	Tue Aug 21 15:45:24 2007 +0200
@@ -840,9 +840,15 @@
     @return: the absolute page name
     """
     if pagename.startswith(PARENT_PREFIX):
-        pagename = '/'.join([x for x in context.split('/')[:-1] + [pagename[PARENT_PREFIX_LEN:]] if x])
+        while context and pagename.startswith(PARENT_PREFIX):
+            context = '/'.join(context.split('/')[:-1])
+            pagename = pagename[PARENT_PREFIX_LEN:]
+        pagename = '/'.join(filter(None, [ context, pagename, ]))
     elif pagename.startswith(CHILD_PREFIX):
-        pagename = context + '/' + pagename[CHILD_PREFIX_LEN:]
+        if context:
+            pagename = context + '/' + pagename[CHILD_PREFIX_LEN:]
+        else:
+            pagename = pagename[CHILD_PREFIX_LEN:]
     return pagename
 
 def pagelinkmarkup(pagename):