Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix uploaded CSS files to use correct relative paths for images

  • Loading branch information...
commit e10b38687859da316ef16308c456401aeaab90a4 1 parent 0061b9c
John Lindal authored
1  TODO
View
@@ -1,6 +1,5 @@
combo,combo-dev
support https
- fix relative url's in css files -- only relative path, to support both http and https
npm modules
17 server/upload.js
View
@@ -340,12 +340,23 @@ exports.configure = function(y, app, argv)
return;
}
- // copy, because rename doesn't work across filesystems
+ // copy, because (1) rename doesn't work across filesystems
+ // and (2) we need to modify css image paths
mod_fs.readFile(file.path, tasks.add(function(err, contents)
{
- var p = data.path + '/' + path;
- mod_mkdirp.sync(mod_path.dirname(p), dir_perm);
+ var p = data.path + '/' + path,
+ d = mod_path.dirname(p);
+ mod_mkdirp.sync(d, dir_perm);
+
+ var info = mod_content_type.analyze(Y, path);
+ if (info && info.type == 'text/css')
+ {
+ // use only relative path, to support both http and https
+
+ var d1 = d.replace(argv.path, '').replace(/^\/+/, '');
+ contents = contents.toString().replace(/url\s*\(\s*(['"]?)([^\)\/])/g, 'url($1' + d1 + '/$2');
+ }
mod_fs.writeFile(p, contents, tasks.add(function(err)
{
2  test/test-combo.pl
View
@@ -49,7 +49,7 @@ ()
my $res = $ua->get('http://127.0.0.1:8666/combo?ns/foo/1.0.f/assets/skins/ace/sp-ns-foo.css&bundle/1.0.z/bundle-bar/assets/skins/sam/bundle-bar.css');
my $code = decode_response($res);
die $code,"\nwrong data" unless
- $code eq slurp('./upload/foo/assets/skins/ace/sp-ns-foo.css')
+ $code eq slurp('./upload-result/foo/1.0.f/sp-ns-foo.css')
.slurp('./upload/bundle1/bundle-bar/assets/skins/sam/bundle-bar.css');
# image
2  test/upload-result/foo/1.0.f/sp-ns-foo.css
View
@@ -0,0 +1,2 @@
+body.yui3-skin-ace {background-color:#66FF66;}
+.foo {background-image:url(ns/foo/1.0.f/assets/skins/ace/warn.png);}
3  test/upload/foo/assets/skins/ace/sp-ns-foo.css
View
@@ -1 +1,2 @@
-body.yui3-skin-ace {background-color:#66FF66;}
+body.yui3-skin-ace {background-color:#66FF66;}
+.foo {background-image:url(warn.png);}
Please sign in to comment.
Something went wrong with that request. Please try again.