2 /* Generated code is not pretty, ignore a lot of this horrorstyle. */
3 /* eslint-disable no-control-regex */
4 /* eslint-disable no-empty */
5 /* eslint-disable security/detect-object-injection */
6 /* eslint-disable brace-style */
7 /* eslint-disable comma-dangle */
8 /* eslint-disable vars-on-top */
9 /* eslint-disable no-unused-vars */
10 /* eslint-disable camelcase */
11 /* eslint-disable indent */
12 /* eslint-disable semi */
13 /* eslint-disable jsdoc/require-jsdoc */
14 /* eslint-disable sonarjs/cognitive-complexity */
15 /* eslint-disable sonarjs/no-identical-functions */
17 function makeString(o) {
21 const onlyFirstAttributes = [
32 // Per-parsing tracking of attributes which should be ignored after first occurrence.
33 let seenAttributes = [];
41 linkValue 'link-value'
42 = uriReference:uriReference OWS attributes:attributes ','? OWS {
50 uriReference 'uri-reference'
51 = '<' uri:uri '>' ';' {
57 return makeString(uri);
60 attributes 'attributes'
62 return attrs.filter((a) => a);
65 linkParam 'link-param'
66 = name:name BWS '=' BWS value:value ';'? OWS {
67 if (onlyFirstAttributes.includes(name.name)) {
68 if (seenAttributes.includes(name.name)) {
69 // Repeat of singleton attribute, ignore it.
72 seenAttributes.push(name.name);
79 / name:name BWS ';'? OWS {
87 = name:[a-zA-Z]+ extended:'*'? {
89 name: makeString(name.concat(extended)).toLowerCase(),
95 = ["] value:[^"]+ ["] {
97 value: makeString(value),
102 value: makeString(value),
112 // This is also an alternate startRule.
113 extendedValue 'extended-value'
114 = encoding:[^']* ['] language:[^']* ['] value:.* {
116 encoding: encoding.length ? makeString(encoding) : 'UTF-8',
117 language: language.length ? makeString(language) : null,
118 value: decodeURIComponent(makeString(value)),
125 value: makeString(value),