diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-03-13 23:59:37 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-03-13 23:59:37 +0100 |
commit | 8320484b88f2481dad276b1912831110fdf75bcd (patch) | |
tree | acbe6cb25cedc0f0b663d26716fb51f209847266 /lib | |
parent | 0e243e6f231d2ce39adcb0020396e877fd1dcaf6 (diff) | |
download | gitbook-8320484b88f2481dad276b1912831110fdf75bcd.zip gitbook-8320484b88f2481dad276b1912831110fdf75bcd.tar.gz gitbook-8320484b88f2481dad276b1912831110fdf75bcd.tar.bz2 |
Fix #647: Fix links normalization (content and hash)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/page.js | 10 |
1 files changed, 5 insertions, 5 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"); |