1 ! Copyright (C) 2004, 2005 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: io hashtables kernel sequences math namespaces ;
6 : file-extension ( filename -- extension )
7 "." split dup length 1 <= [ drop f ] [ peek ] if ;
9 : mime-type ( filename -- mime-type )
10 file-extension "mime-types" get
11 hash [ "text/plain" ] unless* ;
14 { "html" "text/html" }
15 { "txt" "text/plain" }
21 { "jpg" "image/jpeg" }
22 { "jpeg" "image/jpeg" }
24 { "jar" "application/octet-stream" }
25 { "zip" "application/octet-stream" }
26 { "tgz" "application/octet-stream" }
27 { "tar.gz" "application/octet-stream" }
28 { "gz" "application/octet-stream" }
30 { "pdf" "application/pdf" }
32 { "factor" "text/plain" }
33 { "fhtml" "application/x-factor-server-page" }
34 } "mime-types" global set-hash