File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ runnableExamples:
26
26
doAssert m.getMimetype(" fakext" ) == " text/fakelang"
27
27
doAssert m.getMimetype(" FaKeXT" ) == " text/fakelang"
28
28
29
- import strtabs
29
+ import tables
30
30
from strutils import startsWith, toLowerAscii, strip
31
31
32
32
type
33
33
MimeDB* = object
34
- mimes: StringTableRef
34
+ mimes: OrderedTableRef[ string , string ]
35
35
36
36
const mimes* = {
37
37
" 123" : " application/vnd.lotus-1-2-3" ,
@@ -1903,7 +1903,8 @@ const mimes* = {
1903
1903
func newMimetypes* (): MimeDB =
1904
1904
# # Creates a new Mimetypes database. The database will contain the most
1905
1905
# # common mimetypes.
1906
- result .mimes = mimes.newStringTable()
1906
+ {.cast(noSideEffect).}:
1907
+ result .mimes = mimes.newOrderedTable()
1907
1908
1908
1909
func getMimetype* (mimedb: MimeDB, ext: string , default = " text/plain" ): string =
1909
1910
# # Gets mimetype which corresponds to `ext`. Returns `default` if `ext`
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import std/mimetypes
6
6
template main() =
7
7
var m = newMimetypes()
8
8
doAssert m.getMimetype(" mp4" ) == " video/mp4"
9
+ doAssert m.getExt(" application/json" ) == " json"
9
10
# see also `runnableExamples`.
10
11
# xxx we should have a way to avoid duplicating code between runnableExamples and tests
11
12
You can’t perform that action at this time.
0 commit comments