Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Adding support for rootURL option
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmit committed Oct 18, 2016
1 parent a25d9a2 commit dec523b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ SRIHashAssets.prototype.addSRI = function addSRI(string, srcDir) {
var base = this.getBaseHREF(string);

return string.replace(SCRIPT_CHECK, function srcMatch(match) {

var src = match.match(SRC_CHECK);
var filePath;

Expand All @@ -94,6 +93,10 @@ SRIHashAssets.prototype.addSRI = function addSRI(string, srcDir) {

filePath = src[1];

if (plugin.options.rootURL) {
filePath = filePath.replace(new RegExp('^' + plugin.options.rootURL), '');
}

return plugin.mungeOutput(match, filePath, base || srcDir);
}).replace(LINT_CHECK, function hrefMatch(match) {
var href = match.match(HREF_CHECK);
Expand All @@ -106,6 +109,10 @@ SRIHashAssets.prototype.addSRI = function addSRI(string, srcDir) {

filePath = href[1];

if (plugin.options.rootURL) {
filePath = filePath.replace(new RegExp('^' + plugin.options.rootURL), '');
}

return plugin.mungeOutput(match, filePath, base || srcDir);
});
};
Expand Down

0 comments on commit dec523b

Please sign in to comment.