Browse files

hash the filename. 003 now

  • Loading branch information...
1 parent ac29004 commit 1d9453956f37fb01547c1be93658618cd1331367 @pkrumins committed Dec 30, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −2 index.js
  2. +1 −1 package.json
View
7 index.js
@@ -2,19 +2,22 @@ var browserBadge = require('browser-badge');
var fs = require('fs');
var through = require('through');
var path = require('path');
+var crypto = require('crypto');
function cachedBadgeFilename (cacheDir, browsers) {
var browserNames = Object.keys(browsers).sort();
var fileNameParts = [];
browserNames.forEach(function (browserName) {
var browserVersions = Object.keys(browsers[browserName]).sort();
browserVersions.forEach(function (browserVersion) {
- var browser = browserName.substr(0,1) + browserVersion;
+ var browser = browserName + browserVersion;
var success = browsers[browserName][browserVersion] ? 's' : 'f';
fileNameParts.push(browser + success);
});
});
- return cacheDir + '/' + fileNameParts.join('-') + '.png';
+ var fileName = fileNameParts.join('-');
+ var fileNameHash = require('crypto').createHash('md5').update(fileName).digest('hex');
+ return cacheDir + '/' + fileNameHash + '.png';
}
function isCachedBadge (cacheDir, browsers, cb) {
View
2 package.json
@@ -1,6 +1,6 @@
{
"name" : "browser-badge-cached",
- "version" : "0.0.2",
+ "version" : "0.0.3",
"description" : "generate browser version compatibility badges or serve them from cache",
"main" : "index.js",
"directories" : {

0 comments on commit 1d94539

Please sign in to comment.