connect-cachify
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -154,3 +154,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
} else { | ||
return format('%s%s/%s', opts.prefix, hash, filename); | ||
return format('%s%s%s%s', opts.prefix, hash, filename[0] === '/' ? '' : '/', filename); | ||
} | ||
@@ -157,0 +157,0 @@ }; |
@@ -6,3 +6,3 @@ { | ||
"keywords": ["cache", "HTTP", "expires", "asset", "max-age", "caching"], | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"homepage": "http://github.com/mozilla/connect-cachify", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -167,2 +167,41 @@ var cachify = require('../lib/connect-cachify'), | ||
}, | ||
"Production mode with absolute URL in prefix": function (test) { | ||
var assets = make_assets(), | ||
req = { | ||
url: '/v/d41d8cd98f/js/main.min.js' | ||
}, | ||
resp = { | ||
state: {}, | ||
local: function (key, value) { | ||
this.state[key] = value; | ||
}, | ||
setHeader: function (key, value) { | ||
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>', | ||
"Hashes in all urls in production"); | ||
var file = cachify.cachify("/js/main.min.js"); | ||
test.equal(file, "http://example.com/v/d41d8cd98f/js/main.min.js"); | ||
mddlwr(req, resp, function () { | ||
test.ok(resp.state.cachify_js); | ||
test.ok(resp.state.cachify_css); | ||
test.ok(resp.state.cachify); | ||
test.ok(resp.state.header > 0); | ||
test.equal(req.url, '/js/main.min.js'); | ||
test.done(); | ||
}); | ||
}, | ||
"Custom prefix works with non-file assets": function (test) { | ||
@@ -169,0 +208,0 @@ var assets = make_assets(), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42842
496