deno.land / std@0.224.0 / media_types / format_media_type_test.ts

format_media_type_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../assert/mod.ts";import { formatMediaType } from "./mod.ts";
Deno.test({ name: "formatMediaType()", fn() { const fixtures = [ ["/", undefined, ""], ["noslash", { X: "Y" }, "noslash; x=Y"], ["foo bar/baz", undefined, ""], ["foo/bar baz", undefined, ""], [ "attachment", { filename: "ĄĄŽŽČČŠŠ" }, "attachment; filename*=utf-8''%C4%84%C4%84%C5%BD%C5%BD%C4%8C%C4%8C%C5%A0%C5%A0", ], [ "attachment", { filename: "ÁÁÊÊÇÇÎÎ" }, "attachment; filename*=utf-8''%C3%81%C3%81%C3%8A%C3%8A%C3%87%C3%87%C3%8E%C3%8E", ], [ "attachment", { filename: "数据统计.png" }, "attachment; filename*=utf-8''%E6%95%B0%E6%8D%AE%E7%BB%9F%E8%AE%A1.png", ], ["foo/BAR", undefined, "foo/bar"], ["foo/BAR", { "X": "Y" }, "foo/bar; x=Y"], ["foo/BAR", { "space": "With space" }, `foo/bar; space="With space"`], ["foo/BAR", { "quote": `With "quote` }, `foo/bar; quote="With \\"quote"`], [ "foo/BAR", { "bslash": `With \\backslash` }, `foo/bar; bslash="With \\\\backslash"`, ], [ "foo/BAR", { "both": `With \\backslash and "quote` }, `foo/bar; both="With \\\\backslash and \\"quote"`, ], ["foo/BAR", { "": "empty attribute" }, ""], ["foo/BAR", { "bad attribute": "baz" }, ""], [ "foo/BAR", { "nonascii": "not an ascii character: ä" }, "foo/bar; nonascii*=utf-8''not%20an%20ascii%20character%3A%20%C3%A4", ], [ "foo/BAR", { "ctl": "newline: \n nil: \0" }, "foo/bar; ctl*=utf-8''newline%3A%20%0A%20nil%3A%20%00", ], [ "foo/bar", { "a": "av", "b": "bv", "c": "cv" }, "foo/bar; a=av; b=bv; c=cv", ], ["foo/bar", { "0": "'", "9": "'" }, "foo/bar; 0='; 9='"], ["foo", { "bar": "" }, `foo; bar=""`], ["foo/bar", [], "foo/bar"], ] as const; for (const [type, param, expected] of fixtures) { assertEquals(formatMediaType(type, param), expected); } },});
std

Version Info

Tagged at
6 months ago