Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed to not apply absolute prefix for relative urls starting with '#'.

  • Loading branch information...
commit e2fa7ade5a540d8d53f27038278affbc5ef17336 1 parent 7a2e636
Asko Soukka authored
3  docs/HISTORY.txt
View
@@ -1,6 +1,9 @@
History
=======
+* Fixed to not apply absolute prefix for relative urls starting with '#'.
+ [datakurre]
+
0.3 - 2010-05-29
----------------
9 lib/diazo/rules.py
View
@@ -11,7 +11,7 @@
from optparse import OptionParser
from lxml import etree
-from urlparse import urljoin
+from urlparse import urljoin as urlparse_urljoin
from diazo.cssrules import convert_css_selectors
from diazo.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, pkg_xsl, _createOptionParser
@@ -31,6 +31,13 @@
apply_rules = pkg_xsl('apply-rules.xsl')
fixup_themes = pkg_xsl('fixup-themes.xsl')
+def urljoin(base, url, allow_fragments=True):
+ """Join the base with the url only when the url doesn't start with '#'"""
+ if url.startswith('#'):
+ return url
+ else:
+ return urlparse_urljoin(base, url, allow_fragments)
+
def add_identifiers(rules_doc):
"""Add identifiers to the rules for debugging"""
for i, elem in enumerate(rules_doc.xpath(
1  lib/diazo/tests/absolute-prefix/output.html
View
@@ -34,5 +34,6 @@
<input type="submit" src="/foo.jpg" />
<input type="submit" src="http://site.com/foo.jpg" />
<a href="/abs/foo.html">Link</a>
+ <a href="#foo">Anchor</a>
</body>
</html>
1  lib/diazo/tests/absolute-prefix/theme.html
View
@@ -34,5 +34,6 @@
<input type="submit" src="/foo.jpg" />
<input type="submit" src="http://site.com/foo.jpg" />
<a href="foo.html">Link</a>
+ <a href="#foo">Anchor</a>
</body>
</html>

1 comment on commit e2fa7ad

Martin Aspeli

Thanks for this!

Could we call the function something other than urljoin? It's a bit confusing since that name is commonly understood from the standard library.

Martin

Please sign in to comment.
Something went wrong with that request. Please try again.