mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Burn asset-hash utility
refs #9178 - Ghost uses the Node crypto lib always direct (require('crypto')) - it doesn't make sense to outsource a single crypto statement (for the asset hash) - we either have to write a crypto wrapper to avoid writing long crypto statements or we keep the direct usages for every case - for now, wrapping the crypto calls into a lib/crypto has no priority
This commit is contained in:
parent
11a8245ca6
commit
660a407c16
3 changed files with 6 additions and 10 deletions
|
@ -1,7 +1,10 @@
|
|||
var config = require('../../config'),
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto'),
|
||||
config = require('../../config'),
|
||||
blogIconUtils = require('../../utils/blog-icon'),
|
||||
urlService = require('../../services/url'),
|
||||
globalUtils = require('../../utils');
|
||||
packageInfo = require('../../../../package.json');
|
||||
|
||||
/**
|
||||
* Serve either uploaded favicon or default
|
||||
|
@ -38,7 +41,7 @@ function getAssetUrl(path, hasMinFile) {
|
|||
// Ensure we have an assetHash
|
||||
// @TODO rework this!
|
||||
if (!config.get('assetHash')) {
|
||||
config.set('assetHash', globalUtils.generateAssetHash());
|
||||
config.set('assetHash', (crypto.createHash('md5').update(packageInfo.version + Date.now()).digest('hex')).substring(0, 10));
|
||||
}
|
||||
|
||||
// Finally add the asset hash to the output URL
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
var crypto = require('crypto'),
|
||||
packageInfo = require('../../../package.json');
|
||||
|
||||
module.exports = function generateAssetHash() {
|
||||
return (crypto.createHash('md5').update(packageInfo.version + Date.now()).digest('hex')).substring(0, 10);
|
||||
};
|
|
@ -133,7 +133,6 @@ utils = {
|
|||
|
||||
readCSV: require('./read-csv'),
|
||||
zipFolder: require('./zip-folder'),
|
||||
generateAssetHash: require('./asset-hash'),
|
||||
tokens: require('./tokens'),
|
||||
sequence: require('../lib/promise/sequence'),
|
||||
ghostVersion: require('./ghost-version'),
|
||||
|
|
Loading…
Add table
Reference in a new issue