diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2014-04-10 11:44:33 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@gmail.com> | 2014-04-10 11:44:33 -0700 |
commit | 892ec04f5267a2a73074087be6b4eacd13b971a2 (patch) | |
tree | 62b61ab52d3854b9e822b0c6e7fbb82ab1760d06 /lib | |
parent | 02d8272c74b8b7f2da4e39c432e6521047ea8900 (diff) | |
parent | 8f457a752eef936eba95ce3de7bb8e490b1ba4ea (diff) | |
download | gitbook-892ec04f5267a2a73074087be6b4eacd13b971a2.zip gitbook-892ec04f5267a2a73074087be6b4eacd13b971a2.tar.gz gitbook-892ec04f5267a2a73074087be6b4eacd13b971a2.tar.bz2 |
Merge pull request #78 from mrpotes/mocha-windows
Fix URL creation on windows
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse/renderer.js | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js index 86576f0..6b45a22 100644 --- a/lib/parse/renderer.js +++ b/lib/parse/renderer.js @@ -46,16 +46,12 @@ GitBookRenderer.prototype.link = function(href, title, text) { var o = this._extra_options; // Relative link, rewrite it to point to github repo if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.repo && o.dir) { - href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join( - '/', - o.dir, - href - )); + href = url.resolve('https://github.com/' + o.repo + '/blob/', [o.dir, href].join("/")); parsed = url.parse(href); } // Generate HTML for link - var out = '<a href="' + href + '"'; + var out = '<a href="' + parsed.href + '"'; // Title if no null if (title) { out += ' title="' + title + '"'; @@ -80,10 +76,8 @@ GitBookRenderer.prototype.image = function(href, title, text) { // Relative image, rewrite it depending output if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.dir && o.outdir) { - _href = path.relative(o.outdir, path.normalize(path.join( - o.dir, - href - ))); + var outdir = o.outdir.charAt(o.outdir.length - 1) === '/' ? o.outdir : o.outdir + '/'; + _href = url.resolve(outdir, [o.dir, href].join('/')); } return GitBookRenderer.super_.prototype.image.call(this, _href, title, text); |