summaryrefslogtreecommitdiffstats
path: root/lib/utils/links.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/links.js')
-rw-r--r--lib/utils/links.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/utils/links.js b/lib/utils/links.js
index aa7c241..61cdc9a 100644
--- a/lib/utils/links.js
+++ b/lib/utils/links.js
@@ -31,6 +31,11 @@ var isAnchor = function(href) {
return false;
};
+// Normalize a path to be a link
+var normalizeLink = function(s) {
+ return s.replace(/\\/g, '/');
+};
+
// Relative to absolute path
// dir: directory parent of the file currently in rendering process
// outdir: directory parent from the html output
@@ -46,7 +51,7 @@ var toAbsolute = function(_href, dir, outdir) {
_href = path.relative(outdir, hrefInRoot);
// Normalize windows paths
- _href = _href.replace(/\\/g, '/');
+ _href = normalizeLink(_href);
return _href;
};
@@ -55,11 +60,7 @@ var toAbsolute = function(_href, dir, outdir) {
var join = function() {
var _href = path.join.apply(path, arguments);
- if (process.platform === 'win32') {
- _href = _href.replace(/\\/g, '/');
- }
-
- return _href;
+ return normalizeLink(_href);
};
// Change extension
@@ -76,5 +77,6 @@ module.exports = {
isExternal: isExternal,
toAbsolute: toAbsolute,
join: join,
- changeExtension: changeExtension
+ changeExtension: changeExtension,
+ normalize: normalizeLink
};