diff options
Diffstat (limited to 'packages/gitbook-core/src/components/Link.js')
-rw-r--r-- | packages/gitbook-core/src/components/Link.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/gitbook-core/src/components/Link.js b/packages/gitbook-core/src/components/Link.js index ade7461..83ecdd5 100644 --- a/packages/gitbook-core/src/components/Link.js +++ b/packages/gitbook-core/src/components/Link.js @@ -1,5 +1,7 @@ const React = require('react'); const ReactRedux = require('react-redux'); +const path = require('path'); +const url = require('url'); const SummaryArticleShape = require('../shapes/SummaryArticle'); const Link = React.createClass({ @@ -23,9 +25,13 @@ const Link = React.createClass({ return to; } + // Article if (typeof to.ref === 'string') { - // TODO: normalize url - return to.ref; + const parts = url.parse(to.ref); + const ext = path.extname(parts.pathname); + const pathname = path.basename(parts.pathname, ext) + '.html'; + + return pathname + (parts.hash || ''); } }, |