1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

Add resources.substitute back, fix toc promise

This commit is contained in:
Fred Chasen 2016-11-18 21:40:33 +01:00
parent 8edc82244c
commit 662a3e1079
7 changed files with 43 additions and 8 deletions

View file

@ -224,4 +224,22 @@ Resources.prototype.get = function(path) {
}
}
/**
* Substitute urls in content, with replacements,
* relative to a url if provided
* @param {string} content
* @param {[string]} url url to resolve to
* @return {string} content with urls substituted
*/
Resources.prototype.substitute = function(content, url) {
var relUrls;
if (url) {
relUrls = this.relativeTo(url);
} else {
relUrls = this.urls;
}
return replace.substitute(content, relUrls, this.replacementUrls);
};
module.exports = Resources;