Subject: Re: [PATCH] gitweb: use correct mime type even if filename has multiple dots.

From: Jakub Narebski <[email-masked]>
Date: Sun, 17 Sep 2006 10:56:10 +0200

Junio C Hamano wrote:

>> Looking at /etc/mime.types, it only contains pcf.Z but perhaps
>> it should also contain tar.gz or similiar.
> 
> Probably.  But that makes me think it might be better to:
> 
>  - read in mime.types, sort the entries with length of the
>    suffixes (longer first);
> 
>  - try matching the suffixes from longer to shorter and pick the
>    first match.
> 
> Without that, you would not be able to cope with a /etc/mime.types
> that looks like this, no?
> 
>         application/a   a
>         application/b   b.a
> 
> Perhaps something like the attached.

Is it really useful? Usually the suffix in mime.types doesn't contain dot
itself. Besides, to be said we need correct mimetype only for files which
can be displayed in browser (HTML, XHTML, images: png, gif, jpeg, perhaps
XML). All other can get generic mimetype, i.e. application/octet-stream for
binary files (to be saved) and text/plain for text file (to be displayer
as-is in browser).

Besides, performance will suffer for "blob_plain" view. One hash lookup 
vs. nested loops.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git