diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-04-24 23:45:47 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-04-24 23:45:47 +0200 |
commit | 3f5c8acb3cdbf71c429ad331d23698cc53358746 (patch) | |
tree | 6b22b6cc3b447d26ff1867e6899401fa6dfe1374 /lib/output/resolveFile.js | |
parent | 93b257314aa9a6ba240ff7d9534ddb1a6ded6bc0 (diff) | |
download | gitbook-3f5c8acb3cdbf71c429ad331d23698cc53358746.zip gitbook-3f5c8acb3cdbf71c429ad331d23698cc53358746.tar.gz gitbook-3f5c8acb3cdbf71c429ad331d23698cc53358746.tar.bz2 |
Add fiel for testing resolveLinks
Diffstat (limited to 'lib/output/resolveFile.js')
-rw-r--r-- | lib/output/resolveFile.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/output/resolveFile.js b/lib/output/resolveFile.js new file mode 100644 index 0000000..a3a49c5 --- /dev/null +++ b/lib/output/resolveFile.js @@ -0,0 +1,21 @@ +var PathUtils = require('../utils/path'); + +/** + Resolve an absolute path (extracted from a link) + + @param {Output} output + @param {String} filePath + @return {String} +*/ +function resolveFile(output, filePath) { + var pages = output.getPages(); + var page = pages.get(filePath); + + if (!page) { + return filePath; + } + + return PathUtils.setExtension(filePath, '.html'); +} + +module.exports = resolveFile; |