Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zacky1972 committed Dec 25, 2017
1 parent 05a6de8 commit f7da97a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f7da97a

Please sign in to comment.