Skip to content

Commit 554d6a6

Browse files
author
Aaron O'Mullan
committed
Fix URL rewriting error on empty URLs
Fixes GitbookIO#54, fixes GitbookIO#59
1 parent 2182baa commit 554d6a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/parse/renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ GitBookRenderer.prototype.link = function(href, title, text) {
4545

4646
var o = this._extra_options;
4747
// Relative link, rewrite it to point to github repo
48-
if(!parsed.protocol && parsed.path[0] != '/' && o && o.repo && o.dir) {
48+
if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.repo && o.dir) {
4949
href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join(
5050
'/',
5151
o.dir,
@@ -79,7 +79,7 @@ GitBookRenderer.prototype.image = function(href, title, text) {
7979
var o = this._extra_options;
8080

8181
// Relative image, rewrite it depending output
82-
if(!parsed.protocol && parsed.path[0] != '/' && o && o.dir && o.outdir) {
82+
if(!parsed.protocol && parsed.path && parsed.path[0] != '/' && o && o.dir && o.outdir) {
8383
_href = path.relative(o.outdir, path.normalize(path.join(
8484
o.dir,
8585
href

0 commit comments

Comments
 (0)