Merge lp:~sidnei/lazr-js/dont-replace-data-uri into lp:lazr-js

Proposed by Sidnei da Silva
Status: Merged
Merged at revision: 209
Proposed branch: lp:~sidnei/lazr-js/dont-replace-data-uri
Merge into: lp:lazr-js
Diff against target: 67 lines (+44/-2)
2 files modified
src-py/lazr/js/build.py (+4/-2)
src-py/lazr/js/tests/test_combo.py (+40/-0)
To merge this branch: bzr merge lp:~sidnei/lazr-js/dont-replace-data-uri
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+61778@code.launchpad.net

Description of the change

- Don't replace urls if it's a 'data:' uri.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src-py/lazr/js/build.py'
2--- src-py/lazr/js/build.py 2011-03-22 18:43:00 +0000
3+++ src-py/lazr/js/build.py 2011-05-20 14:57:45 +0000
4@@ -150,8 +150,10 @@
5 os.path.sep)
6 def fix_relative_url(match):
7 url = match.group(1)
8- # Don't modify absolute URLs.
9- if url.startswith("http") or url.startswith("/"):
10+ # Don't modify absolute URLs or 'data:' urls.
11+ if (url.startswith("http") or
12+ url.startswith("/") or
13+ url.startswith("data:")):
14 return match.group(0)
15 parts = relative_parts + url.split("/")
16 result = []
17
18=== modified file 'src-py/lazr/js/tests/test_combo.py'
19--- src-py/lazr/js/tests/test_combo.py 2011-01-10 14:36:00 +0000
20+++ src-py/lazr/js/tests/test_combo.py 2011-05-20 14:57:45 +0000
21@@ -142,6 +142,46 @@
22 root=test_dir)).strip(),
23 expected)
24
25+ def test_combine_css_leaves_data_uris_untouched(self):
26+ """
27+ Combining CSS files does not touch data uris in
28+ declarations.
29+ """
30+ test_dir = self.makeDir()
31+
32+ files = [
33+ self.makeSampleFile(
34+ test_dir,
35+ os.path.join("widget", "assets", "skins", "sam", "widget.css"),
36+ """\
37+ /* widget skin */
38+ .yui-widget {
39+ background: url("data:image/gif;base64,base64-data");
40+ }
41+ """),
42+ self.makeSampleFile(
43+ test_dir,
44+ os.path.join("editor", "assets", "skins", "sam", "editor.css"),
45+ """\
46+ /* editor skin */
47+ .yui-editor {
48+ background: url(data:image/gif;base64,base64-data);
49+ }
50+ """),
51+ ]
52+
53+ expected = "\n".join(
54+ ('/* widget/assets/skins/sam/widget.css */',
55+ '.yui-widget{background:url("data:image/gif;base64,base64-data")}',
56+ '/* editor/assets/skins/sam/editor.css */',
57+ '.yui-editor{background:url("data:image/gif;base64,base64-data")}',
58+ ))
59+ self.assertEquals(
60+ "".join(combine_files(["widget/assets/skins/sam/widget.css",
61+ "editor/assets/skins/sam/editor.css"],
62+ root=test_dir)).strip(),
63+ expected)
64+
65 def test_combine_css_disable_minify(self):
66 """
67 It is possible to disable CSS minification altogether, while

Subscribers

People subscribed via source and target branches