[xwiki-devs] XWikiServletURLFactory#getURL(URL, XWikiContext) behavior

Marius Dumitru Florea mariusdumitru.florea at xwiki.com
Tue Nov 23 09:07:39 CET 2010

Hi devs,

In revision 30548 (for XE 2.5M1, see 
http://jira.xwiki.org/jira/browse/XWIKI-5386 ) I changed the behaviour 
of the XWikiServletURLFactory#getURL(URL, XWikiContext) method. It used 
to make URLs relative to the current request URL and now it makes URLs 
relative to the current wiki (set on the xwiki context). Let's take an 

request URL: http://playground.xwiki.org/xwiki/bin/view/Sandbox/TestURL
current wiki (set from velocity script): code (code.xwiki.org)
URL 1: http://code.xwiki.org/xwiki/bin/view/Main/WebHome
URL 2: http://playground.xwiki.org/xwiki/bin/view/Spage/Page

Before: (1) http://code.xwiki.org/xwiki/bin/view/Main/WebHome
         (2) /xwiki/bin/view/Spage/Page

Now: (1) /xwiki/bin/view/Main/WebHome
      (2) http://playground.xwiki.org/xwiki/bin/view/Spage/Page

The javadoc of XWikiServletURLFactory#getURL(URL, XWikiContext) is not 
clear on this:

  * Converts a URL to a relative URL if it's a XWiki URL (keeping only 
the path + query string + anchor) and leave
  * the URL unchanged if it's an external URL.
  * @param url the URL to convert
  * @return the converted URL as a string

So what's the correct behaviour?


More information about the devs mailing list