blob: 3dba8f76f5cb41d59ff90d5410612271d454adac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
var LocationUtils = require('../../utils/location');
var fileToURL = require('./fileToURL');
/**
Resolve an absolute path (extracted from a link)
@param {Output} output
@param {String} filePath
@return {String}
*/
function resolveFileToURL(output, filePath) {
// Convert /test.png -> test.png
filePath = LocationUtils.toAbsolute(filePath, '', '');
var pages = output.getPages();
var page = pages.get(filePath);
// if file is a page, return correct .html url
if (page) {
filePath = fileToURL(output, filePath);
}
return LocationUtils.normalize(filePath);
}
module.exports = resolveFileToURL;
|