Server for file: URLs
Configuration parameters for this server:
function FileServer(config) {
BaseServer.call(this, config);
}
FileServer.prototype = Object.create(BaseServer.prototype);
FileServer.prototype.constructor = FileServer;
Determines whether we can serve local file.
FileServer.prototype.canServe = function (localPath) {
// FileServer requires that the base URL is undefined and static HTML files
return (!this._baseUrl && LiveDevelopmentUtils.isStaticHtmlFileExt(localPath));
};
Returns a file: URL for a given absolute path
FileServer.prototype.pathToUrl = function (path) {
return encodeURI(PREFIX + path);
};
exports.FileServer = FileServer;
});
Convert a file: URL to a absolute file path
FileServer.prototype.urlToPath = function (url) {
if (url.indexOf(PREFIX) === 0) {
// Convert a file URL to local file path
return decodeURI(url.slice(PREFIX.length));
}
return null;
};