summaryrefslogtreecommitdiffstats
path: root/lib/utils/page.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/page.js')
-rw-r--r--lib/utils/page.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/utils/page.js b/lib/utils/page.js
index cdc7d1a..effa24f 100644
--- a/lib/utils/page.js
+++ b/lib/utils/page.js
@@ -1,5 +1,6 @@
var Q = require('q');
var _ = require('lodash');
+var url = require('url');
var path = require('path');
var cheerio = require('cheerio');
var domSerializer = require('dom-serializer');
@@ -186,8 +187,12 @@ function normalizeHtml(src, options) {
var href = $(this).attr("href");
if (!href) return;
- if (links.isRelative(href)) {
- var absolutePath = path.join(options.base, href);
+ 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;
// If is in navigation relative: transform as content
if (options.navigation[absolutePath]) {
@@ -195,8 +200,9 @@ function normalizeHtml(src, options) {
}
// Transform as absolute
- href = links.toAbsolute(href, options.base, options.output);
+ href = links.toAbsolute(href, options.base, options.output)+anchor;
} else {
+ // External links
$(this).attr("target", "_blank");
}