it('throws an error if a name is empty', () => {
[
[',', 0],
['foo,,', 4],
['foo, ,', 6],
['foo;=', 4],
['foo; =', 5],
['foo;;', 4],
['foo; ;', 5],
['foo;bar=,', 8],
['foo;bar=""', 9]
].forEach((element) => { assert.throws(
() => parse(element[0]), new RegExp(
`^SyntaxError: Unexpected character at index ${element[1]}$`
)
);
});
});
it('throws an error if a white space is misplaced', () => {
[
[' foo', 0],
['f oo', 2],
['foo;ba r', 7],
['foo;bar =', 8],
['foo;bar= ', 8],
['foo;bar=ba z', 11]
].forEach((element) => { assert.throws(
() => parse(element[0]), new RegExp(
`^SyntaxError: Unexpected character at index ${element[1]}$`
)
);
});
});
it('throws an error if a token contains invalid characters', () => {
[
['f@o', 1],
['f\\oo', 1],
['"foo"', 0],
['f"oo"', 1],
['foo;b@r', 5],
['foo;b\\ar', 5],
['foo;"bar"', 4],
['foo;b"ar"', 5],
['foo;bar=b@z', 9],
['foo;bar=b\\az ', 9],
['foo;bar="b@z"', 10],
['foo;bar="baz;"', 12],
['foo;bar=b"az"', 9],
['foo;bar="\\\\"', 10]
].forEach((element) => { assert.throws(
() => parse(element[0]), new RegExp(
`^SyntaxError: Unexpected character at index ${element[1]}$`
)
);
});
});
it('throws an error if the header value ends prematurely', () => {
[ '', 'foo ', 'foo\t', 'foo, ', 'foo;', 'foo;bar ', 'foo;bar,', 'foo;bar; ', 'foo;bar=', 'foo;bar="baz', 'foo;bar="1\\', 'foo;bar="baz" '
].forEach((header) => { assert.throws(
() => parse(header),
/^SyntaxError: Unexpected end of input$/
);
});
});
});
describe('format', () => {
it('formats a single extension', () => { const extensions = format({ foo: {} });
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.