26 lines
898 B
JavaScript
26 lines
898 B
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const location_1 = __importDefault(require("../../utils/location"));
|
|
const fileToURL_1 = __importDefault(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 = location_1.default.toAbsolute(filePath, "", "");
|
|
const page = output.getPage(filePath);
|
|
// if file is a page, return correct .html url
|
|
if (page) {
|
|
filePath = (0, fileToURL_1.default)(output, filePath);
|
|
}
|
|
return location_1.default.normalize(filePath);
|
|
}
|
|
exports.default = resolveFileToURL;
|