summaryrefslogtreecommitdiff
path: root/cli/media_type.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-02-18 15:37:05 +1100
committerGitHub <noreply@github.com>2021-02-18 15:37:05 +1100
commit2225e83da2d118678e3df1e2801af195166bc65a (patch)
tree0d33bdf77e19872a72fca4364281c6cc14ec5724 /cli/media_type.rs
parent78e34d49120d8cc2583d8d6d28ae9b74f9765533 (diff)
fix(lsp): handle data URLs properly (#9522)
Fixes #9514 Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/media_type.rs')
-rw-r--r--cli/media_type.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/cli/media_type.rs b/cli/media_type.rs
index db64b3922..761de0ca0 100644
--- a/cli/media_type.rs
+++ b/cli/media_type.rs
@@ -121,8 +121,8 @@ impl MediaType {
///
/// *NOTE* This is defined in TypeScript as a string based enum. Changes to
/// that enum in TypeScript should be reflected here.
- pub fn as_ts_extension(&self) -> String {
- let ext = match self {
+ pub fn as_ts_extension(&self) -> &str {
+ match self {
MediaType::JavaScript => ".js",
MediaType::JSX => ".jsx",
MediaType::TypeScript => ".ts",
@@ -138,13 +138,11 @@ impl MediaType {
// JS for mapping purposes, though in reality, it is unlikely to ever be
// passed to the compiler.
MediaType::SourceMap => ".js",
- // TypeScript doesn't have an "unknown", so we will treat WASM as JS for
- // mapping purposes, though in reality, it is unlikely to ever be passed
- // to the compiler.
+ // TypeScript doesn't have an "unknown", so we will treat unknowns as JS
+ // for mapping purposes, though in reality, it is unlikely to ever be
+ // passed to the compiler.
MediaType::Unknown => ".js",
- };
-
- ext.into()
+ }
}
/// Map the media type to a `ts.ScriptKind`