Skip to content

Commit

Permalink
fix(mime): fix preferredExtension()
Browse files Browse the repository at this point in the history
- fix low-priority file ext handling
- add `.markdown` as low-pri (prefer more common `.md` ext)
  • Loading branch information
postspectacular committed Apr 10, 2021
1 parent 46eef16 commit 2ebe6ed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/mime/src/generated.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* generated @ 2021-04-04T15:01:57.202Z - DO NOT EDIT!
* generated @ 2021-04-10T11:16:38.116Z - DO NOT EDIT!
*
* @internal
*/
Expand Down Expand Up @@ -481,7 +481,7 @@ export const DB: Record<string, Record<string, string>> = {
jade: "jade",
jsx: "jsx",
less: "less",
markdown: "markdown,md",
markdown: "*markdown,md",
mathml: "mml",
mdx: "mdx",
n3: "n3",
Expand Down
4 changes: 2 additions & 2 deletions packages/mime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ export const preferredType = (ext: string, fallback = MIME_TYPES.bin[0]) => {
export const preferredExtension = (mime: string, fallback = "bin") => {
const [prefix, suffix] = mime.split("/");
const group = DB[prefix];
const ext = group ? group[suffix] : undefined;
return ext ? ext.split(",")[0] : fallback;
const ext = group ? group[suffix].split(",") : undefined;
return ext ? ext.find((x) => x[0] !== "*") || ext[0].substr(1) : fallback;
};
1 change: 1 addition & 0 deletions packages/mime/tools/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const INCLUDE = new Set<string>([
const LO_PRIORITIES: IObjectOf<string> = {
"3gpp": "audio/3gpp",
jpm: "video/jpm",
markdown: "text/markdown",
mp3: "audio/mp3",
rtf: "text/rtf",
wav: "audio/wave",
Expand Down

0 comments on commit 2ebe6ed

Please sign in to comment.