diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-28 21:54:03 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-28 21:54:03 +0100 |
commit | 0494f7d1fd084f843cbca09aeb8e23ebb4075730 (patch) | |
tree | 9feb9f6a682abf4dffda68d00d5f5ce67500fc82 /lib | |
parent | 4aa66338fce505566a2fe6ba6aee79ddf3f656a2 (diff) | |
download | gitbook-0494f7d1fd084f843cbca09aeb8e23ebb4075730.zip gitbook-0494f7d1fd084f843cbca09aeb8e23ebb4075730.tar.gz gitbook-0494f7d1fd084f843cbca09aeb8e23ebb4075730.tar.bz2 |
Fix #1165: correctly normalize path in summary to accept unicode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backbone/summary.js | 3 | ||||
-rw-r--r-- | lib/utils/location.js | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js index a79b1e9..5a2f7f2 100644 --- a/lib/backbone/summary.js +++ b/lib/backbone/summary.js @@ -39,6 +39,9 @@ function TOCArticle(def, parent) { 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); } } diff --git a/lib/utils/location.js b/lib/utils/location.js index ba0c57d..ba43644 100644 --- a/lib/utils/location.js +++ b/lib/utils/location.js @@ -27,7 +27,7 @@ function isAnchor(href) { // Normalize a path to be a link function normalize(s) { - return s.replace(/\\/g, '/'); + return path.normalize(s).replace(/\\/g, '/'); } // Convert relative to absolute path @@ -36,7 +36,7 @@ function normalize(s) { function toAbsolute(_href, dir, outdir) { if (isExternal(_href)) return _href; outdir = outdir == undefined? dir : outdir; - + _href = normalize(_href); dir = normalize(dir); outdir = normalize(outdir); |