2 /* Generated code is not pretty, ignore a lot of this horrorstyle. */
3 /* eslint-disable quotes */
4 /* eslint-disable vars-on-top */
5 /* eslint-disable no-control-regex */
6 /* eslint-disable security/detect-object-injection */
7 /* eslint-disable vars-on-top */
8 /* eslint-disable brace-style */
9 /* eslint-disable comma-dangle */
10 /* eslint-disable no-unused-vars */
12 function makeString(o) {
16 const onlyFirstAttributes = [
27 // Per-parsing tracking of attributes which should be ignored after first occurrence.
28 let seenAttributes = [];
36 linkValue 'link-value'
37 = uriReference:uriReference OWS attributes:attributes ','? OWS {
45 uriReference 'uri-reference'
46 = '<' uri:uri '>' ';' {
52 return makeString(uri);
55 attributes 'attributes'
57 return attrs.filter((a) => a);
60 linkParam 'link-param'
61 = name:name BWS '=' BWS value:value ';'? OWS {
62 if (onlyFirstAttributes.includes(name.name)) {
63 if (seenAttributes.includes(name.name)) {
64 // Repeat of singleton attribute, ignore it.
67 seenAttributes.push(name.name);
74 / name:name BWS ';'? OWS {
82 = name:[a-zA-Z]+ extended:'*'? {
84 name: makeString(name.concat(extended)).toLowerCase(),
90 = ["] value:[^"]+ ["] {
92 value: makeString(value),
97 value: makeString(value),
107 // This is also an alternate startRule.
108 extendedValue 'extended-value'
109 = encoding:[^']* ['] language:[^']* ['] value:.* {
111 encoding: encoding.length ? makeString(encoding) : 'UTF-8',
112 language: language.length ? makeString(language) : null,
113 value: decodeURIComponent(makeString(value)),
120 value: makeString(value),