summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/utils/page.js10
-rw-r--r--test/json.js2
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/utils/page.js b/lib/utils/page.js
index dade47b..689cf74 100644
--- a/lib/utils/page.js
+++ b/lib/utils/page.js
@@ -190,17 +190,17 @@ function normalizeHtml(src, options) {
if (links.isAnchor(href)) {
// Keep it as it is
} else if (links.isRelative(href)) {
- var parts = url.parse(path.join(options.base, href));
- var absolutePath = parts.pathname;
- var anchor = parts.hash;
+ var parts = url.parse(href);
+ var absolutePath = path.join(options.base, parts.pathname);
+ var anchor = parts.hash || "";
// If is in navigation relative: transform as content
if (options.navigation[absolutePath]) {
- href = options.book.contentLink(href);
+ absolutePath = options.book.contentLink(absolutePath);
}
// Transform as absolute
- href = links.toAbsolute(href, options.base, options.output)+anchor;
+ href = links.toAbsolute("/"+absolutePath, options.base, options.output)+anchor;
} else {
// External links
$(this).attr("target", "_blank");
diff --git a/test/json.js b/test/json.js
index e0ad14f..c600ffa 100644
--- a/test/json.js
+++ b/test/json.js
@@ -21,7 +21,7 @@ describe('JSON generator', function () {
assert(fs.existsSync(path.join(output, "sub/test1.json")));
var test1 = JSON.parse(fs.readFileSync(path.join(output, "sub/test1.json")));
- assert(test1.sections[0].content.indexOf("intro.html") > 0);
+ assert(test1.sections[0].content.indexOf("index.html") > 0);
}, done);
});