mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
add content encoding to the response headers when the server returns js, csv or tsv
This commit is contained in:
@@ -4,6 +4,7 @@ export class KnownFileType {
|
||||
public static readonly JSON = new KnownFileType('json', 'application/json');
|
||||
public static readonly CSV = new KnownFileType('csv', 'text/csv');
|
||||
public static readonly TSV = new KnownFileType('tsv', 'text/tab-separated-values');
|
||||
public static readonly TXT = new KnownFileType('txt', 'text/text');
|
||||
public static readonly MARKDOWN = new KnownFileType('md', 'text/markdown');
|
||||
public static readonly JS = new KnownFileType('js', 'application/javascript');
|
||||
public static readonly JPG = new KnownFileType('jpg', 'image/jpeg');
|
||||
@@ -18,6 +19,14 @@ export class KnownFileType {
|
||||
KnownFileType.allInstancesByExtension[extension] = this;
|
||||
}
|
||||
|
||||
public isSameType(contentType: string): boolean {
|
||||
if (!contentType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.contentType === contentType || contentType.indexOf(this.contentType) === 0;
|
||||
}
|
||||
|
||||
public formatFileName(fileName: string): string {
|
||||
if (fileName.endsWith(`.${this.extension}`)) {
|
||||
return fileName;
|
||||
|
||||
Reference in New Issue
Block a user