Skip to content

Commit 52ff8f5

Browse files
committed
Add '#' to constant NON_REWRITEABLE_URL
Pipeline was ignoring HTML anchor tags as valid URLs, and would erroneously prepend a relative directory path to the anchor tag. This fix adds the octothorpe (#) to the constant NON_REWRITEABLE_URL to allow the anchor tag to be ignored as a valid URL link.
1 parent e6498ac commit 52ff8f5

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ or just made Pipeline more awesome.
3939
* Denis V Seleznyov <[email protected]>
4040
* DJ Sharkey <[email protected]>
4141
* Edwin Lunando <[email protected]>
42+
* Eric Hamiter <[email protected]>
4243
* Evan Myller <[email protected]>
4344
* Fabian Büchler <[email protected]>
4445
* Feanil Patel <[email protected]>

pipeline/compressors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
URL_DETECTOR = r"""url\((['"]){0,1}\s*(.*?)["']{0,1}\)"""
1818
URL_REPLACER = r"""url\(__EMBED__(.+?)(\?\d+)?\)"""
19-
NON_REWRITABLE_URL = re.compile(r'^(http:|https:|data:|//)')
19+
NON_REWRITABLE_URL = re.compile(r'^(#|http:|https:|data:|//)')
2020

2121
DEFAULT_TEMPLATE_FUNC = "template"
2222
TEMPLATE_FUNC = r"""var template = function(str){var fn = new Function('obj', 'var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(\''+str.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/<%=([\s\S]+?)%>/g,function(match,code){return "',"+code.replace(/\\'/g, "'")+",'";}).replace(/<%([\s\S]+?)%>/g,function(match,code){return "');"+code.replace(/\\'/g, "'").replace(/[\r\n\t]/g,' ')+"__p.push('";}).replace(/\r/g,'\\r').replace(/\n/g,'\\n').replace(/\t/g,'\\t')+"');}return __p.join('');");return fn;};"""

tests/assets/css/urls.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
.no-protocol-url {
2222
background-image: url(//images/sprite-buttons.png);
2323
}
24+
.anchor-tag-url {
25+
background-image: url(#image-gradient);
26+
}
2427
@font-face{src:url(../fonts/pipeline.eot);src:url(../fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../fonts/pipeline.woff) format('woff'),url(../fonts/pipeline.ttf) format('truetype');}

tests/tests/test_compressor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def test_url_rewrite(self):
153153
.no-protocol-url {
154154
background-image: url(//images/sprite-buttons.png);
155155
}
156+
.anchor-tag-url {
157+
background-image: url(#image-gradient);
158+
}
156159
@font-face{src:url(../pipeline/fonts/pipeline.eot);src:url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../pipeline/fonts/pipeline.woff) format('woff'),url(../pipeline/fonts/pipeline.ttf) format('truetype');}
157160
""", output)
158161

0 commit comments

Comments
 (0)