diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-05-12 12:19:00 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-05-12 12:19:00 +0200 |
commit | a091c5b331282bbcc4e0a3b79fbc32dd6f842747 (patch) | |
tree | 39bcc8a395111f059f4e65dc44f072b28a3d10a3 /lib/utils/location.js | |
parent | 784b3379b50bb0c2986efaca55940d14feb10d3a (diff) | |
download | gitbook-a091c5b331282bbcc4e0a3b79fbc32dd6f842747.zip gitbook-a091c5b331282bbcc4e0a3b79fbc32dd6f842747.tar.gz gitbook-a091c5b331282bbcc4e0a3b79fbc32dd6f842747.tar.bz2 |
Fix path resolution when generating page with conrefs
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); |