structured-field-values
Version:
Implementation of Structured Field Values from IETF httpbis RFC8941
109 lines (108 loc) • 3.63 kB
JSON
[
{
"name": "basic parameterised list",
"raw": ["abc_123;a=1;b=2; cdef_456, ghi;q=9;r=\"+w\""],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "abc_123"}, [["a", 1], ["b", 2], ["cdef_456", true]]],
[{"__type": "token", "value": "ghi"}, [["q", 9], ["r", "+w"]]]
],
"canonical": ["abc_123;a=1;b=2;cdef_456, ghi;q=9;r=\"+w\""]
},
{
"name": "single item parameterised list",
"raw": ["text/html;q=1.0"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, [["q", 1.0]]]
]
},
{
"name": "missing parameter value parameterised list",
"raw": ["text/html;a;q=1.0"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, [["a", true], ["q", 1.0]]]
]
},
{
"name": "missing terminal parameter value parameterised list",
"raw": ["text/html;q=1.0;a"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, [["q", 1.0], ["a", true]]]
]
},
{
"name": "no whitespace parameterised list",
"raw": ["text/html,text/plain;q=0.5"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, []],
[{"__type": "token", "value": "text/plain"}, [["q", 0.5]]]
],
"canonical": ["text/html, text/plain;q=0.5"]
},
{
"name": "whitespace before = parameterised list",
"raw": ["text/html, text/plain;q =0.5"],
"header_type": "list",
"must_fail": true
},
{
"name": "whitespace after = parameterised list",
"raw": ["text/html, text/plain;q= 0.5"],
"header_type": "list",
"must_fail": true
},
{
"name": "whitespace before ; parameterised list",
"raw": ["text/html, text/plain ;q=0.5"],
"header_type": "list",
"must_fail": true
},
{
"name": "whitespace after ; parameterised list",
"raw": ["text/html, text/plain; q=0.5"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, []],
[{"__type": "token", "value": "text/plain"}, [["q", 0.5]]]
],
"canonical": ["text/html, text/plain;q=0.5"]
},
{
"name": "extra whitespace parameterised list",
"raw": ["text/html , text/plain; q=0.5; charset=utf-8"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, []],
[{"__type": "token", "value": "text/plain"},
[["q", 0.5], ["charset", {"__type": "token", "value": "utf-8"}
]]]
],
"canonical": ["text/html, text/plain;q=0.5;charset=utf-8"]
},
{
"name": "two lines parameterised list",
"raw": ["text/html", "text/plain;q=0.5"],
"header_type": "list",
"expected": [
[{"__type": "token", "value": "text/html"}, []],
[{"__type": "token", "value": "text/plain"}, [["q", 0.5]]]
],
"canonical": ["text/html, text/plain;q=0.5"]
},
{
"name": "trailing comma parameterised list",
"raw": ["text/html,text/plain;q=0.5,"],
"header_type": "list",
"must_fail": true
},
{
"name": "empty item parameterised list",
"raw": ["text/html,,text/plain;q=0.5,"],
"header_type": "list",
"must_fail": true
}
]