MCPcopy Index your code
hub / github.com/11ty/dev-server / getFileContentType

Method getFileContentType

server.js:434–455  ·  view source on GitHub ↗
(filepath, res)

Source from the content-addressed store, hash-verified

432 }
433
434 getFileContentType(filepath, res) {
435 let contentType = res.getHeader("Content-Type");
436
437 // Content-Type might be already set via middleware
438 if (contentType) {
439 return contentType;
440 }
441
442 let mimeType = mime.getType(filepath);
443 if (!mimeType) {
444 return;
445 }
446
447 contentType = mimeType;
448
449 // We only want to append charset if the header is not already set
450 if (contentType === "text/html") {
451 contentType = `text/html; charset=${this.options.encoding}`;
452 }
453
454 return contentType;
455 }
456
457 renderFile(filepath, res) {
458 let contents = fs.readFileSync(filepath);

Callers 1

renderFileMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected