Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
asset-rev-debugging
AssetRewrite.prototype.processString = function (string, relativePath) {
var newString = string;
for (var i = 0, keyLength = this.assetMapKeys.length; i < keyLength; i++) {
var key = this.assetMapKeys[i];
// Start timer
console.time(key);
if (this.assetMap.hasOwnProperty(key)) {
/*
* Rewrite absolute URLs
*/
newString = this.rewriteAssetPath(newString, key, this.assetMap[key]);
/*
* Rewrite relative URLs. If there is a prepend, use the full absolute path.
*/
var pathDiff = relative(relativePath, key).replace(/^\.\//, "");
var replacementDiff = relative(relativePath, this.assetMap[key]).replace(/^\.\//, "");
if (this.prepend && this.prepend !== '') {
replacementDiff = this.assetMap[key];
}
newString = this.rewriteAssetPath(newString, pathDiff, replacementDiff);
}
// End timer
console.timeEnd(key);
}
return newString;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment