2 /* Generated code is not pretty, ignore a lot of this horrorstyle. */
3 /* eslint-disable no-control-regex */
4 /* eslint-disable security/detect-object-injection */
5 /* eslint-disable brace-style */
6 /* eslint-disable comma-dangle */
7 /* eslint-disable vars-on-top */
8 /* eslint-disable no-unused-vars */
9 /* eslint-disable camelcase */
10 /* eslint-disable indent */
11 /* eslint-disable semi */
12 /* eslint-disable jsdoc/require-jsdoc */
13 /* eslint-disable sonarjs/cognitive-complexity */
14 /* eslint-disable sonarjs/no-identical-functions */
16 function makeString(o) {
20 const onlyFirstAttributes = [
31 // Per-parsing tracking of attributes which should be ignored after first occurrence.
32 let seenAttributes = [];
40 linkValue 'link-value'
41 = uriReference:uriReference OWS attributes:attributes ','? OWS {
49 uriReference 'uri-reference'
50 = '<' uri:uri '>' ';' {
56 return makeString(uri);
59 attributes 'attributes'
61 return attrs.filter((a) => a);
64 linkParam 'link-param'
65 = name:name BWS '=' BWS value:value ';'? OWS {
66 if (onlyFirstAttributes.includes(name.name)) {
67 if (seenAttributes.includes(name.name)) {
68 // Repeat of singleton attribute, ignore it.
71 seenAttributes.push(name.name);
78 / name:name BWS ';'? OWS {
86 = name:[a-zA-Z]+ extended:'*'? {
88 name: makeString(name.concat(extended)).toLowerCase(),
94 = ["] value:[^"]+ ["] {
96 value: makeString(value),
101 value: makeString(value),
111 // This is also an alternate startRule.
112 extendedValue 'extended-value'
113 = encoding:[^']* ['] language:[^']* ['] value:.* {
115 encoding: encoding.length ? makeString(encoding) : 'UTF-8',
116 language: language.length ? makeString(language) : null,
117 value: decodeURIComponent(makeString(value)),
124 value: makeString(value),