@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
49 lines • 1.44 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MediaType = void 0;
class MediaType {
constructor(init) {
this.type = init.type;
this.mainType = init.mainType;
this.subType = init.subType;
this.delimiter = init.delimiter;
this.firstSuffix = init.firstSuffix;
this.mimeSuffix = init.mimeSuffix;
this.suffixesCSV = init.suffixesCSV;
}
/**
* Returns the subtype part of the MIME type.
* If subType is empty, try to extract it from the full type string.
*/
sub() {
if (this.subType) {
return this.subType;
}
const parts = this.type.split('/');
if (parts.length === 2) {
const subTypeParts = parts[1].split('+');
return subTypeParts[0];
}
return '';
}
/**
* Returns the MIME suffix, e.g. "xml" from "application/rss+xml"
*/
getMimeSuffix() {
if (this.mimeSuffix)
return this.mimeSuffix;
const plusIndex = this.type.indexOf('+');
if (plusIndex !== -1) {
return this.type.substring(plusIndex + 1);
}
return undefined;
}
/**
* Returns the list of suffixes if defined.
*/
getSuffixList() {
return this.suffixesCSV ? this.suffixesCSV.split(',') : [];
}
}
exports.MediaType = MediaType;
//# sourceMappingURL=type.js.map