Handle correctly path starting with "/"

This commit is contained in:
Samy Pessé
2015-01-28 13:17:41 +01:00
parent 534edaceac
commit 4e620f34ad
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ var isRelative = function(href) {
try {
var parsed = url.parse(href);
return !parsed.protocol && parsed.path && parsed.path[0] != '/';
return !!(!parsed.protocol && parsed.path);// && parsed.path[0] != '/';
} catch(err) {}
return true;
+3 -1
View File
@@ -154,7 +154,7 @@ function normalizeHtml(src, options) {
function convertImages(images, options) {
return _.reduce(images, function(prev, image) {
return prev.then(function() {
var imgin = links. isExternal(image.source)? image.source : path.resolve(options.book.root, image.source);
var imgin = links. isExternal(image.source)? image.source : path.resolve(options.book.options.output, image.source);
var imgout = path.resolve(options.book.options.output, image.dest);
options.book.log.debug("convert image", image.source, "to", image.dest, "...");
@@ -210,6 +210,8 @@ function normalizePage(sections, options) {
return Q()
.then(function() {
toConvert = _.uniq(toConvert, 'source');
return convertImages(toConvert, options);
})
.thenResolve(sections);