Skip to content

Commit

Permalink
chore: replace deprecated typeByExtension() in content_type.ts (d…
Browse files Browse the repository at this point in the history
…enoland#3727)

chore: Replace deprecated `typeByExtension` in `content_type.ts`

Signed-off-by: Oscar <[email protected]>
Co-authored-by: Asher Gomez <[email protected]>
  • Loading branch information
0scvr and iuioiua committed Oct 28, 2023
1 parent 33684a2 commit 22cc48d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion media_types/content_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// This module is browser compatible.

import { parseMediaType } from "./parse_media_type.ts";
import { typeByExtension } from "./type_by_extension.ts";
import { getCharset } from "./get_charset.ts";
import { formatMediaType } from "./format_media_type.ts";
import type { db } from "./_db.ts";
import { types } from "./_db.ts";

type DB = typeof db;
type ContentTypeToExtension = {
Expand Down Expand Up @@ -75,3 +75,9 @@ export function contentType<
return undefined as Lowercase<T> extends KnownExtensionOrType ? string
: string | undefined;
}

function typeByExtension(extension: string): string | undefined {
extension = extension.startsWith(".") ? extension.slice(1) : extension;
// @ts-ignore workaround around denoland/dnt#148
return types.get(extension.toLowerCase());
}

0 comments on commit 22cc48d

Please sign in to comment.