diff options
Diffstat (limited to 'lib/utils/location.js')
-rw-r--r-- | lib/utils/location.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/utils/location.js b/lib/utils/location.js index b2ac813..17edc00 100644 --- a/lib/utils/location.js +++ b/lib/utils/location.js @@ -40,7 +40,7 @@ function normalize(s) { } /** - Convert relative to absolute path + Convert a relative path to absolute @param {String} href @param {String} dir: directory parent of the file currently in rendering process @@ -48,7 +48,10 @@ function normalize(s) { @return {String} */ function toAbsolute(_href, dir, outdir) { - if (isExternal(_href) || isDataURI(_href)) return _href; + if (isExternal(_href) || isDataURI(_href)) { + return _href; + } + outdir = outdir == undefined? dir : outdir; _href = normalize(_href); @@ -56,8 +59,10 @@ function toAbsolute(_href, dir, outdir) { outdir = normalize(outdir); // Path "_href" inside the base folder - var hrefInRoot = path.normalize(path.join(dir, _href)); - if (_href[0] == '/') hrefInRoot = path.normalize(_href.slice(1)); + var hrefInRoot = normalize(path.join(dir, _href)); + if (_href[0] == '/') { + hrefInRoot = normalize(_href.slice(1)); + } // Make it relative to output _href = path.relative(outdir, hrefInRoot); |