Browse files

Refactored to not mix anchor_safe_urljoin with regular urljoin and us…

…e it only when necessary.
  • Loading branch information...
1 parent e2fa7ad commit 62cdcb7bb0c77bd3f4f63f9411706a899e7273e2 @datakurre datakurre committed Apr 11, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/diazo/
@@ -11,7 +11,7 @@
from optparse import OptionParser
from lxml import etree
-from urlparse import urljoin as urlparse_urljoin
+from urlparse import urljoin
from diazo.cssrules import convert_css_selectors
from diazo.utils import namespaces, fullname, AC_READ_NET, AC_READ_FILE, pkg_xsl, _createOptionParser
@@ -31,12 +31,12 @@
apply_rules = pkg_xsl('apply-rules.xsl')
fixup_themes = pkg_xsl('fixup-themes.xsl')
-def urljoin(base, url, allow_fragments=True):
+def anchor_safe_urljoin(base, url):
"""Join the base with the url only when the url doesn't start with '#'"""
if url.startswith('#'):
return url
- return urlparse_urljoin(base, url, allow_fragments)
+ return urljoin(base, url)
def add_identifiers(rules_doc):
"""Add identifiers to the rules for debugging"""
@@ -110,7 +110,7 @@ def apply_absolute_prefix(theme_doc, absolute_prefix):
url = urljoin(absolute_prefix, node.get('src'))
node.set('src', url)
for node in theme_doc.xpath('//*[@href]'):
- url = urljoin(absolute_prefix, node.get('href'))
+ url = anchor_safe_urljoin(absolute_prefix, node.get('href'))
node.set('href', url)
for node in theme_doc.xpath('//style'):
node.text = IMPORT_STYLESHEET.sub(

0 comments on commit 62cdcb7

Please sign in to comment.