From f7da97a54b33ac0195d7d4a84b36473418b2dc6e Mon Sep 17 00:00:00 2001 From: Susumu Yamazaki Date: Mon, 25 Dec 2017 20:56:09 +0900 Subject: [PATCH] fix #79 --- index.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ea345c0..dcda9ae 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,15 @@ var through = require('through2'); var utils = require('./utils'); +function encodeURI(obj) { + return obj.split('/').map(function(obj) { + return obj.split('.').map(function(obj) { + return encodeURIComponent(obj); + }).join('.'); + }).join('/'); +} + + function plugin(options) { var renames = []; var cache = []; @@ -58,10 +67,19 @@ function plugin(options) { options.manifest.on('data', function (file) { var manifest = JSON.parse(file.contents.toString()); Object.keys(manifest).forEach(function (srcFile) { + var canonicalizedSrcFile = canonicalizeUri(srcFile); + var canonicalizedManifestSrcFile = canonicalizeUri(manifest[srcFile]); renames.push({ - unreved: canonicalizeUri(srcFile), - reved: options.prefix + canonicalizeUri(manifest[srcFile]) + unreved: canonicalizedSrcFile, + reved: options.prefix + canonicalizedManifestSrcFile }); + var encodedSrcFile = encodeURI(canonicalizedSrcFile); + if(canonicalizedSrcFile !== encodedSrcFile) { + renames.push({ + unreved: encodedSrcFile, + reved: options.prefix + encodeURI(canonicalizedManifestSrcFile) + }) + } }); }); options.manifest.on('end', replaceContents);