add a test for prefixes with url's, fix a formatting bug where filename ... #15

Merged
merged 1 commit into from Jun 13, 2012

Projects

None yet

2 participants

@lloyd
Contributor
lloyd commented Jun 13, 2012

...starts with '/'

This fixes a bug when using absolute urls in prefixes where cachify puts a double slash before the filename (i.e. https://static.personatest.org/v/5cb95f4060//production/browserid.css)

mind reviewing, merging, and pushing a new version?

@ozten ozten was assigned Jun 13, 2012
@ozten ozten commented on the diff Jun 13, 2012
lib/connect-cachify.js
@@ -151,7 +151,7 @@ var hashify = function (filename, hash) {
filename[0] === '/') {
return format('/%s%s%s', opts.prefix, hash, filename);
} else {
- return format('%s%s/%s', opts.prefix, hash, filename);
+ return format('%s%s%s%s', opts.prefix, hash, filename[0] === '/' ? '' : '/', filename);
@ozten
ozten Jun 13, 2012 Member

Thanks for making this more flexible.

@ozten ozten commented on the diff Jun 13, 2012
test/connect-cachify-test.js
+ this.state[key] = value;
+ if (!this.state['header']) this.state['header'] = 0;
+ this.state['header'] += 1;
+ },
+ on: function (name, cb) {
+
+ }
+ },
+ mddlwr;
+ mddlwr = cachify.setup(
+ assets, {
+ root: '/tmp',
+ prefix: 'http://example.com/v/'
+ });
+ var link = cachify.cachify_js("/js/main.min.js");
+ test.equal(link, '<script src="http://example.com/v/d41d8cd98f/js/main.min.js"></script>',
@ozten
ozten Jun 13, 2012 Member

Right on. Thanks for writing a repro case.

@ozten ozten merged commit cdf6a3b into master Jun 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment