tmimetypes.nim 805 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. targets: "c js"
  4. """
  5. import std/mimetypes
  6. import std/assertions
  7. template main() =
  8. var m = newMimetypes()
  9. doAssert m.getMimetype("mp4") == "video/mp4"
  10. doAssert m.getExt("application/json") == "json"
  11. doAssert m.getMimetype("json") == "application/json"
  12. m.register("foo", "baa")
  13. doAssert m.getMimetype("foo") == "baa"
  14. doAssert m.getMimetype("txt") == "text/plain"
  15. doAssert m.getExt("text/plain") == "txt"
  16. # see also `runnableExamples`.
  17. # xxx we should have a way to avoid duplicating code between runnableExamples and tests
  18. doAssert m.getMimetype("nim") == "text/nim"
  19. doAssert m.getMimetype("nimble") == "text/nimble"
  20. doAssert m.getMimetype("nimf") == "text/nim"
  21. doAssert m.getMimetype("nims") == "text/nim"
  22. static: main()
  23. main()