/** * Find an asset in a map of asset names to their files. If the searched asset name has a pipe * symbol in it, the part after that is seen as the extension of the file we look for. * * @param {Object} assetFileNames * @param {string} assetName * @return {string} */ function findAsset (assetFileNames, assetName) { const [assetFileName, assetExtension] = assetName.split('|'); const assets = assetFileNames[assetFileName]; const [asset] = assets.filter(function hasExtension (asset) { return assetExtension ? asset.split('.').pop() === assetExtension : asset; }); return asset; } module.exports = findAsset;