mimetypes.nim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Dominik Picheta
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. ## This module implements a mimetypes database
  10. import strtabs
  11. type
  12. MimeDB* = object
  13. mimes: StringTableRef
  14. const mimes* = {
  15. "ez": "application/andrew-inset",
  16. "anx": "application/annodex",
  17. "atom": "application/atom+xml",
  18. "atomcat": "application/atomcat+xml",
  19. "atomsrv": "application/atomserv+xml",
  20. "lin": "application/bbolin",
  21. "cap": "application/cap",
  22. "pcap": "application/cap",
  23. "cu": "application/cu-seeme",
  24. "davmount": "application/davmount+xml",
  25. "tsp": "application/dsptype",
  26. "es": "application/ecmascript",
  27. "spl": "application/futuresplash",
  28. "hta": "application/hta",
  29. "jar": "application/java-archive",
  30. "ser": "application/java-serialized-object",
  31. "class": "application/java-vm",
  32. "js": "application/javascript",
  33. "m3g": "application/m3g",
  34. "hqx": "application/mac-binhex40",
  35. "cpt": "application/mac-compactpro",
  36. "nb": "application/mathematica",
  37. "nbp": "application/mathematica",
  38. "mdb": "application/msaccess",
  39. "doc": "application/msword",
  40. "dot": "application/msword",
  41. "mxf": "application/mxf",
  42. "bin": "application/octet-stream",
  43. "oda": "application/oda",
  44. "ogx": "application/ogg",
  45. "pdf": "application/pdf",
  46. "key": "application/pgp-keys",
  47. "pgp": "application/pgp-signature",
  48. "prf": "application/pics-rules",
  49. "ps": "application/postscript",
  50. "ai": "application/postscript",
  51. "eps": "application/postscript",
  52. "epsi": "application/postscript",
  53. "epsf": "application/postscript",
  54. "eps2": "application/postscript",
  55. "eps3": "application/postscript",
  56. "rar": "application/rar",
  57. "rdf": "application/rdf+xml",
  58. "rss": "application/rss+xml",
  59. "rtf": "application/rtf",
  60. "smi": "application/smil",
  61. "smil": "application/smil",
  62. "xhtml": "application/xhtml+xml",
  63. "xht": "application/xhtml+xml",
  64. "xml": "application/xml",
  65. "xsl": "application/xml",
  66. "xsd": "application/xml",
  67. "xspf": "application/xspf+xml",
  68. "zip": "application/zip",
  69. "apk": "application/vnd.android.package-archive",
  70. "cdy": "application/vnd.cinderella",
  71. "kml": "application/vnd.google-earth.kml+xml",
  72. "kmz": "application/vnd.google-earth.kmz",
  73. "xul": "application/vnd.mozilla.xul+xml",
  74. "xls": "application/vnd.ms-excel",
  75. "xlb": "application/vnd.ms-excel",
  76. "xlt": "application/vnd.ms-excel",
  77. "cat": "application/vnd.ms-pki.seccat",
  78. "stl": "application/vnd.ms-pki.stl",
  79. "ppt": "application/vnd.ms-powerpoint",
  80. "pps": "application/vnd.ms-powerpoint",
  81. "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  82. "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
  83. "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  84. "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
  85. "potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
  86. "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  87. "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
  88. "cod": "application/vnd.rim.cod",
  89. "mmf": "application/vnd.smaf",
  90. "sis": "application/vnd.symbian.install",
  91. "vsd": "application/vnd.visio",
  92. "wbxml": "application/vnd.wap.wbxml",
  93. "wmlc": "application/vnd.wap.wmlc",
  94. "wmlsc": "application/vnd.wap.wmlscriptc",
  95. "wpd": "application/vnd.wordperfect",
  96. "wp5": "application/vnd.wordperfect5.1",
  97. "wk": "application/x-123",
  98. "7z": "application/x-7z-compressed",
  99. "abw": "application/x-abiword",
  100. "dmg": "application/x-apple-diskimage",
  101. "bcpio": "application/x-bcpio",
  102. "torrent": "application/x-bittorrent",
  103. "cab": "application/x-cab",
  104. "cbr": "application/x-cbr",
  105. "cbz": "application/x-cbz",
  106. "cdf": "application/x-cdf",
  107. "cda": "application/x-cdf",
  108. "vcd": "application/x-cdlink",
  109. "pgn": "application/x-chess-pgn",
  110. "cpio": "application/x-cpio",
  111. "csh": "application/x-csh",
  112. "deb": "application/x-debian-package",
  113. "udeb": "application/x-debian-package",
  114. "dcr": "application/x-director",
  115. "dir": "application/x-director",
  116. "dxr": "application/x-director",
  117. "dms": "application/x-dms",
  118. "wad": "application/x-doom",
  119. "dvi": "application/x-dvi",
  120. "rhtml": "application/x-httpd-eruby",
  121. "pfa": "application/x-font",
  122. "pfb": "application/x-font",
  123. "gsf": "application/x-font",
  124. "pcf": "application/x-font",
  125. "pcf.Z": "application/x-font",
  126. "mm": "application/x-freemind",
  127. "spl": "application/x-futuresplash",
  128. "gnumeric": "application/x-gnumeric",
  129. "sgf": "application/x-go-sgf",
  130. "gcf": "application/x-graphing-calculator",
  131. "gtar": "application/x-gtar",
  132. "tgz": "application/x-gtar",
  133. "taz": "application/x-gtar",
  134. "hdf": "application/x-hdf",
  135. "phtml": "application/x-httpd-php",
  136. "pht": "application/x-httpd-php",
  137. "php": "application/x-httpd-php",
  138. "phps": "application/x-httpd-php-source",
  139. "php3": "application/x-httpd-php3",
  140. "php3p": "application/x-httpd-php3-preprocessed",
  141. "php4": "application/x-httpd-php4",
  142. "php5": "application/x-httpd-php5",
  143. "ica": "application/x-ica",
  144. "info": "application/x-info",
  145. "ins": "application/x-internet-signup",
  146. "isp": "application/x-internet-signup",
  147. "iii": "application/x-iphone",
  148. "iso": "application/x-iso9660-image",
  149. "jam": "application/x-jam",
  150. "jnlp": "application/x-java-jnlp-file",
  151. "jmz": "application/x-jmol",
  152. "chrt": "application/x-kchart",
  153. "kil": "application/x-killustrator",
  154. "skp": "application/x-koan",
  155. "skd": "application/x-koan",
  156. "skt": "application/x-koan",
  157. "skm": "application/x-koan",
  158. "kpr": "application/x-kpresenter",
  159. "kpt": "application/x-kpresenter",
  160. "ksp": "application/x-kspread",
  161. "kwd": "application/x-kword",
  162. "kwt": "application/x-kword",
  163. "latex": "application/x-latex",
  164. "lha": "application/x-lha",
  165. "lyx": "application/x-lyx",
  166. "lzh": "application/x-lzh",
  167. "lzx": "application/x-lzx",
  168. "frm": "application/x-maker",
  169. "maker": "application/x-maker",
  170. "frame": "application/x-maker",
  171. "fm": "application/x-maker",
  172. "fb": "application/x-maker",
  173. "book": "application/x-maker",
  174. "fbdoc": "application/x-maker",
  175. "mif": "application/x-mif",
  176. "wmd": "application/x-ms-wmd",
  177. "wmz": "application/x-ms-wmz",
  178. "com": "application/x-msdos-program",
  179. "exe": "application/x-msdos-program",
  180. "bat": "application/x-msdos-program",
  181. "dll": "application/x-msdos-program",
  182. "msi": "application/x-msi",
  183. "nc": "application/x-netcdf",
  184. "pac": "application/x-ns-proxy-autoconfig",
  185. "dat": "application/x-ns-proxy-autoconfig",
  186. "nwc": "application/x-nwc",
  187. "o": "application/x-object",
  188. "oza": "application/x-oz-application",
  189. "p7r": "application/x-pkcs7-certreqresp",
  190. "crl": "application/x-pkcs7-crl",
  191. "pyc": "application/x-python-code",
  192. "pyo": "application/x-python-code",
  193. "qgs": "application/x-qgis",
  194. "shp": "application/x-qgis",
  195. "shx": "application/x-qgis",
  196. "qtl": "application/x-quicktimeplayer",
  197. "rpm": "application/x-redhat-package-manager",
  198. "rb": "application/x-ruby",
  199. "sh": "application/x-sh",
  200. "shar": "application/x-shar",
  201. "swf": "application/x-shockwave-flash",
  202. "swfl": "application/x-shockwave-flash",
  203. "scr": "application/x-silverlight",
  204. "sit": "application/x-stuffit",
  205. "sitx": "application/x-stuffit",
  206. "sv4cpio": "application/x-sv4cpio",
  207. "sv4crc": "application/x-sv4crc",
  208. "tar": "application/x-tar",
  209. "tcl": "application/x-tcl",
  210. "gf": "application/x-tex-gf",
  211. "pk": "application/x-tex-pk",
  212. "texinfo": "application/x-texinfo",
  213. "texi": "application/x-texinfo",
  214. "~": "application/x-trash",
  215. "%": "application/x-trash",
  216. "bak": "application/x-trash",
  217. "old": "application/x-trash",
  218. "sik": "application/x-trash",
  219. "t": "application/x-troff",
  220. "tr": "application/x-troff",
  221. "roff": "application/x-troff",
  222. "man": "application/x-troff-man",
  223. "me": "application/x-troff-me",
  224. "ms": "application/x-troff-ms",
  225. "ustar": "application/x-ustar",
  226. "src": "application/x-wais-source",
  227. "wz": "application/x-wingz",
  228. "crt": "application/x-x509-ca-cert",
  229. "xcf": "application/x-xcf",
  230. "fig": "application/x-xfig",
  231. "xpi": "application/x-xpinstall",
  232. "wasm": "application/wasm",
  233. "amr": "audio/amr",
  234. "awb": "audio/amr-wb",
  235. "amr": "audio/amr",
  236. "awb": "audio/amr-wb",
  237. "axa": "audio/annodex",
  238. "au": "audio/basic",
  239. "snd": "audio/basic",
  240. "flac": "audio/flac",
  241. "mid": "audio/midi",
  242. "midi": "audio/midi",
  243. "kar": "audio/midi",
  244. "mpga": "audio/mpeg",
  245. "mpega": "audio/mpeg",
  246. "mp2": "audio/mpeg",
  247. "mp3": "audio/mpeg",
  248. "m4a": "audio/mpeg",
  249. "m3u": "audio/mpegurl",
  250. "oga": "audio/ogg",
  251. "ogg": "audio/ogg",
  252. "spx": "audio/ogg",
  253. "sid": "audio/prs.sid",
  254. "aif": "audio/x-aiff",
  255. "aiff": "audio/x-aiff",
  256. "aifc": "audio/x-aiff",
  257. "gsm": "audio/x-gsm",
  258. "m3u": "audio/x-mpegurl",
  259. "wma": "audio/x-ms-wma",
  260. "wax": "audio/x-ms-wax",
  261. "ra": "audio/x-pn-realaudio",
  262. "rm": "audio/x-pn-realaudio",
  263. "ram": "audio/x-pn-realaudio",
  264. "ra": "audio/x-realaudio",
  265. "pls": "audio/x-scpls",
  266. "sd2": "audio/x-sd2",
  267. "wav": "audio/x-wav",
  268. "alc": "chemical/x-alchemy",
  269. "cac": "chemical/x-cache",
  270. "cache": "chemical/x-cache",
  271. "csf": "chemical/x-cache-csf",
  272. "cbin": "chemical/x-cactvs-binary",
  273. "cascii": "chemical/x-cactvs-binary",
  274. "ctab": "chemical/x-cactvs-binary",
  275. "cdx": "chemical/x-cdx",
  276. "cer": "chemical/x-cerius",
  277. "c3d": "chemical/x-chem3d",
  278. "chm": "chemical/x-chemdraw",
  279. "cif": "chemical/x-cif",
  280. "cmdf": "chemical/x-cmdf",
  281. "cml": "chemical/x-cml",
  282. "cpa": "chemical/x-compass",
  283. "bsd": "chemical/x-crossfire",
  284. "csml": "chemical/x-csml",
  285. "csm": "chemical/x-csml",
  286. "ctx": "chemical/x-ctx",
  287. "cxf": "chemical/x-cxf",
  288. "cef": "chemical/x-cxf",
  289. "smi": "#chemical/x-daylight-smiles",
  290. "emb": "chemical/x-embl-dl-nucleotide",
  291. "embl": "chemical/x-embl-dl-nucleotide",
  292. "spc": "chemical/x-galactic-spc",
  293. "inp": "chemical/x-gamess-input",
  294. "gam": "chemical/x-gamess-input",
  295. "gamin": "chemical/x-gamess-input",
  296. "fch": "chemical/x-gaussian-checkpoint",
  297. "fchk": "chemical/x-gaussian-checkpoint",
  298. "cub": "chemical/x-gaussian-cube",
  299. "gau": "chemical/x-gaussian-input",
  300. "gjc": "chemical/x-gaussian-input",
  301. "gjf": "chemical/x-gaussian-input",
  302. "gal": "chemical/x-gaussian-log",
  303. "gcg": "chemical/x-gcg8-sequence",
  304. "gen": "chemical/x-genbank",
  305. "hin": "chemical/x-hin",
  306. "istr": "chemical/x-isostar",
  307. "ist": "chemical/x-isostar",
  308. "jdx": "chemical/x-jcamp-dx",
  309. "dx": "chemical/x-jcamp-dx",
  310. "kin": "chemical/x-kinemage",
  311. "mcm": "chemical/x-macmolecule",
  312. "mmd": "chemical/x-macromodel-input",
  313. "mmod": "chemical/x-macromodel-input",
  314. "mol": "chemical/x-mdl-molfile",
  315. "rd": "chemical/x-mdl-rdfile",
  316. "rxn": "chemical/x-mdl-rxnfile",
  317. "sd": "chemical/x-mdl-sdfile",
  318. "sdf": "chemical/x-mdl-sdfile",
  319. "tgf": "chemical/x-mdl-tgf",
  320. "mif": "#chemical/x-mif",
  321. "mcif": "chemical/x-mmcif",
  322. "mol2": "chemical/x-mol2",
  323. "b": "chemical/x-molconn-Z",
  324. "gpt": "chemical/x-mopac-graph",
  325. "mop": "chemical/x-mopac-input",
  326. "mopcrt": "chemical/x-mopac-input",
  327. "mpc": "chemical/x-mopac-input",
  328. "zmt": "chemical/x-mopac-input",
  329. "moo": "chemical/x-mopac-out",
  330. "mvb": "chemical/x-mopac-vib",
  331. "asn": "chemical/x-ncbi-asn1",
  332. "prt": "chemical/x-ncbi-asn1-ascii",
  333. "ent": "chemical/x-ncbi-asn1-ascii",
  334. "val": "chemical/x-ncbi-asn1-binary",
  335. "aso": "chemical/x-ncbi-asn1-binary",
  336. "asn": "chemical/x-ncbi-asn1-spec",
  337. "pdb": "chemical/x-pdb",
  338. "ent": "chemical/x-pdb",
  339. "ros": "chemical/x-rosdal",
  340. "sw": "chemical/x-swissprot",
  341. "vms": "chemical/x-vamas-iso14976",
  342. "vmd": "chemical/x-vmd",
  343. "xtel": "chemical/x-xtel",
  344. "xyz": "chemical/x-xyz",
  345. "gif": "image/gif",
  346. "ief": "image/ief",
  347. "jpeg": "image/jpeg",
  348. "jpg": "image/jpeg",
  349. "jpe": "image/jpeg",
  350. "pcx": "image/pcx",
  351. "png": "image/png",
  352. "svg": "image/svg+xml",
  353. "svgz": "image/svg+xml",
  354. "tiff": "image/tiff",
  355. "tif": "image/tiff",
  356. "djvu": "image/vnd.djvu",
  357. "djv": "image/vnd.djvu",
  358. "wbmp": "image/vnd.wap.wbmp",
  359. "cr2": "image/x-canon-cr2",
  360. "crw": "image/x-canon-crw",
  361. "ras": "image/x-cmu-raster",
  362. "cdr": "image/x-coreldraw",
  363. "pat": "image/x-coreldrawpattern",
  364. "cdt": "image/x-coreldrawtemplate",
  365. "cpt": "image/x-corelphotopaint",
  366. "erf": "image/x-epson-erf",
  367. "ico": "image/x-icon",
  368. "art": "image/x-jg",
  369. "jng": "image/x-jng",
  370. "bmp": "image/x-ms-bmp",
  371. "nef": "image/x-nikon-nef",
  372. "orf": "image/x-olympus-orf",
  373. "psd": "image/x-photoshop",
  374. "pnm": "image/x-portable-anymap",
  375. "pbm": "image/x-portable-bitmap",
  376. "pgm": "image/x-portable-graymap",
  377. "ppm": "image/x-portable-pixmap",
  378. "rgb": "image/x-rgb",
  379. "xbm": "image/x-xbitmap",
  380. "xpm": "image/x-xpixmap",
  381. "xwd": "image/x-xwindowdump",
  382. "eml": "message/rfc822",
  383. "igs": "model/iges",
  384. "iges": "model/iges",
  385. "msh": "model/mesh",
  386. "mesh": "model/mesh",
  387. "silo": "model/mesh",
  388. "wrl": "model/vrml",
  389. "vrml": "model/vrml",
  390. "x3dv": "model/x3d+vrml",
  391. "x3d": "model/x3d+xml",
  392. "x3db": "model/x3d+binary",
  393. "manifest": "text/cache-manifest",
  394. "ics": "text/calendar",
  395. "icz": "text/calendar",
  396. "css": "text/css",
  397. "csv": "text/csv",
  398. "323": "text/h323",
  399. "html": "text/html",
  400. "htm": "text/html",
  401. "shtml": "text/html",
  402. "uls": "text/iuls",
  403. "mml": "text/mathml",
  404. "asc": "text/plain",
  405. "txt": "text/plain",
  406. "text": "text/plain",
  407. "pot": "text/plain",
  408. "brf": "text/plain",
  409. "rtx": "text/richtext",
  410. "sct": "text/scriptlet",
  411. "wsc": "text/scriptlet",
  412. "tm": "text/texmacs",
  413. "ts": "text/texmacs",
  414. "tsv": "text/tab-separated-values",
  415. "jad": "text/vnd.sun.j2me.app-descriptor",
  416. "wml": "text/vnd.wap.wml",
  417. "wmls": "text/vnd.wap.wmlscript",
  418. "bib": "text/x-bibtex",
  419. "boo": "text/x-boo",
  420. "h++": "text/x-c++hdr",
  421. "hpp": "text/x-c++hdr",
  422. "hxx": "text/x-c++hdr",
  423. "hh": "text/x-c++hdr",
  424. "c++": "text/x-c++src",
  425. "cpp": "text/x-c++src",
  426. "cxx": "text/x-c++src",
  427. "cc": "text/x-c++src",
  428. "h": "text/x-chdr",
  429. "htc": "text/x-component",
  430. "csh": "text/x-csh",
  431. "c": "text/x-csrc",
  432. "d": "text/x-dsrc",
  433. "diff": "text/x-diff",
  434. "patch": "text/x-diff",
  435. "hs": "text/x-haskell",
  436. "java": "text/x-java",
  437. "lhs": "text/x-literate-haskell",
  438. "moc": "text/x-moc",
  439. "p": "text/x-pascal",
  440. "pas": "text/x-pascal",
  441. "gcd": "text/x-pcs-gcd",
  442. "pl": "text/x-perl",
  443. "pm": "text/x-perl",
  444. "py": "text/x-python",
  445. "scala": "text/x-scala",
  446. "etx": "text/x-setext",
  447. "sh": "text/x-sh",
  448. "tcl": "text/x-tcl",
  449. "tk": "text/x-tcl",
  450. "tex": "text/x-tex",
  451. "ltx": "text/x-tex",
  452. "sty": "text/x-tex",
  453. "cls": "text/x-tex",
  454. "vcs": "text/x-vcalendar",
  455. "vcf": "text/x-vcard",
  456. "3gp": "video/3gpp",
  457. "axv": "video/annodex",
  458. "dl": "video/dl",
  459. "dif": "video/dv",
  460. "dv": "video/dv",
  461. "fli": "video/fli",
  462. "gl": "video/gl",
  463. "mpeg": "video/mpeg",
  464. "mpg": "video/mpeg",
  465. "mpe": "video/mpeg",
  466. "mp4": "video/mp4",
  467. "qt": "video/quicktime",
  468. "mov": "video/quicktime",
  469. "ogv": "video/ogg",
  470. "mxu": "video/vnd.mpegurl",
  471. "flv": "video/x-flv",
  472. "lsf": "video/x-la-asf",
  473. "lsx": "video/x-la-asf",
  474. "mng": "video/x-mng",
  475. "asf": "video/x-ms-asf",
  476. "asx": "video/x-ms-asf",
  477. "wm": "video/x-ms-wm",
  478. "wmv": "video/x-ms-wmv",
  479. "wmx": "video/x-ms-wmx",
  480. "wvx": "video/x-ms-wvx",
  481. "avi": "video/x-msvideo",
  482. "movie": "video/x-sgi-movie",
  483. "mpv": "video/x-matroska",
  484. "mkv": "video/x-matroska",
  485. "ice": "x-conference/x-cooltalk",
  486. "sisx": "x-epoc/x-sisx-app",
  487. "vrm": "x-world/x-vrml",
  488. "vrml": "x-world/x-vrml",
  489. "wrl": "x-world/x-vrml"}
  490. from strutils import startsWith
  491. proc newMimetypes*(): MimeDB =
  492. ## Creates a new Mimetypes database. The database will contain the most
  493. ## common mimetypes.
  494. result.mimes = mimes.newStringTable()
  495. proc getMimetype*(mimedb: MimeDB, ext: string, default = "text/plain"): string =
  496. ## Gets mimetype which corresponds to ``ext``. Returns ``default`` if ``ext``
  497. ## could not be found. ``ext`` can start with an optional dot which is ignored.
  498. if ext.startsWith("."):
  499. result = mimedb.mimes.getOrDefault(ext.substr(1))
  500. else:
  501. result = mimedb.mimes.getOrDefault(ext)
  502. if result == "":
  503. return default
  504. proc getExt*(mimedb: MimeDB, mimetype: string, default = "txt"): string =
  505. ## Gets extension which corresponds to ``mimetype``. Returns ``default`` if
  506. ## ``mimetype`` could not be found. Extensions are returned without the
  507. ## leading dot.
  508. result = default
  509. for e, m in mimedb.mimes:
  510. if m == mimetype:
  511. result = e
  512. proc register*(mimedb: var MimeDB, ext: string, mimetype: string) =
  513. ## Adds ``mimetype`` to the ``mimedb``.
  514. mimedb.mimes[ext] = mimetype
  515. when isMainModule:
  516. var m = newMimetypes()
  517. assert m.getMimetype("mp4") == "video/mp4"
  518. assert m.getExt("text/html") == "html"