summaryrefslogtreecommitdiffstats
path: root/lib/backbone
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-03-07 10:40:25 +0100
committerSamy Pessé <samypesse@gmail.com>2016-03-07 10:40:25 +0100
commitb4bdf97cfe84994a4e2e04f196e0ebb4849b188f (patch)
treeeabe2904fb68684960c469a6286f1628eaea0bd0 /lib/backbone
parentbf98984012c493aebb2258902e1722f0ed0d3527 (diff)
downloadgitbook-b4bdf97cfe84994a4e2e04f196e0ebb4849b188f.zip
gitbook-b4bdf97cfe84994a4e2e04f196e0ebb4849b188f.tar.gz
gitbook-b4bdf97cfe84994a4e2e04f196e0ebb4849b188f.tar.bz2
Fix linting errors
Diffstat (limited to 'lib/backbone')
-rw-r--r--lib/backbone/summary.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js
index 5a2f7f2..9c8a38d 100644
--- a/lib/backbone/summary.js
+++ b/lib/backbone/summary.js
@@ -1,6 +1,5 @@
var _ = require('lodash');
var util = require('util');
-var url = require('url');
var location = require('../utils/location');
var error = require('../utils/error');
@@ -32,17 +31,13 @@ function TOCArticle(def, parent) {
// Path can be a relative path or an url, or nothing
this.ref = def.path;
- if (this.ref) {
- var parts = url.parse(this.ref);
+ if (this.ref && !this.isExternal()) {
+ var parts = this.ref.split('#');
+ this.path = (parts.length > 1? parts.slice(0, -1).join('#') : this.ref);
+ this.anchor = (parts.length > 1? '#' + _.last(parts) : null);
- if (!this.isExternal()) {
- var parts = this.ref.split('#');
- this.path = (parts.length > 1? parts.slice(0, -1).join('#') : this.ref);
- this.anchor = (parts.length > 1? '#' + _.last(parts) : null);
-
- // Normalize path to remove ('./', etc)
- this.path = location.normalize(this.path);
- }
+ // Normalize path to remove ('./', etc)
+ this.path = location.normalize(this.path);
}
this.articles = _.map(def.articles || [], function(article) {