Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily create .mime files only with mismatch/no extension #1417

Merged
merged 3 commits into from
Dec 27, 2018

Conversation

kevinkassimo
Copy link
Contributor

Closes #1333

src/deno_dir.rs Outdated
@@ -28,6 +29,17 @@ pub struct CodeFetchOutput {
pub maybe_source_map: Option<Vec<u8>>,
}

lazy_static! {
// Using str as key, since MediaType does not impl Eq and Hash
static ref EXTENSION_MAP: HashMap<&'static str, msg::MediaType> = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using a static HashMap for this, I think it would be simpler to have a function: fn extmap(ext: &str) -> MediaType

src/deno_dir.rs Outdated
// Create .mime file only when content type different from extension
let resolved_content_type = map_content_type(&p, Some(&content_type));
let dot_index = filename.rfind(".").unwrap_or(0);
let ext = filename.chars().skip(dot_index).collect::<String>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not some dedicated std function for extracting the extension ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't been able to find a proper one... I could have used byte slices but that is not quite safe in case of non-ascii characters...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks Kevin

@ry ry merged commit 73fb98c into denoland:master Dec 27, 2018
@kevinkassimo kevinkassimo deleted the mime/lazy branch December 27, 2019 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants