• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NaturalIntelligence / fast-xml-parser / 22910077419

10 Mar 2026 03:23PM UTC coverage: 97.837% (+0.1%) from 97.689%
22910077419

push

github

amitguptagwl
update dependency

1110 of 1154 branches covered (96.19%)

9228 of 9432 relevant lines covered (97.84%)

473155.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.09
/src/xmlparser/OptionsBuilder.js
1
export const defaultOptions = {
5✔
2
  preserveOrder: false,
5✔
3
  attributeNamePrefix: '@_',
5✔
4
  attributesGroupName: false,
5✔
5
  textNodeName: '#text',
5✔
6
  ignoreAttributes: true,
5✔
7
  removeNSPrefix: false, // remove NS from tag name or attribute name if true
5✔
8
  allowBooleanAttributes: false, //a tag can have attributes without any value
5✔
9
  //ignoreRootElement : false,
5✔
10
  parseTagValue: true,
5✔
11
  parseAttributeValue: false,
5✔
12
  trimValues: true, //Trim string values of tag and attributes
5✔
13
  cdataPropName: false,
5✔
14
  numberParseOptions: {
5✔
15
    hex: true,
5✔
16
    leadingZeros: true,
5✔
17
    eNotation: true
5✔
18
  },
5✔
19
  tagValueProcessor: function (tagName, val) {
5✔
20
    return val;
1,810✔
21
  },
5✔
22
  attributeValueProcessor: function (attrName, val) {
5✔
23
    return val;
1,195✔
24
  },
5✔
25
  stopNodes: [], //nested tags will not be parsed even for errors
5✔
26
  alwaysCreateTextNode: false,
5✔
27
  isArray: () => false,
5✔
28
  commentPropName: false,
5✔
29
  unpairedTags: [],
5✔
30
  processEntities: true,
5✔
31
  htmlEntities: false,
5✔
32
  ignoreDeclaration: false,
5✔
33
  ignorePiTags: false,
5✔
34
  transformTagName: false,
5✔
35
  transformAttributeName: false,
5✔
36
  updateTag: function (tagName, jPath, attrs) {
5✔
37
    return tagName
6,265✔
38
  },
5✔
39
  // skipEmptyListItem: false
5✔
40
  captureMetaData: false,
5✔
41
  maxNestedTags: 100,
5✔
42
  strictReservedNames: true,
5✔
43
  jPath: true, // if true, pass jPath string to callbacks; if false, pass matcher instance
5✔
44
};
5✔
45

5✔
46
/**
5✔
47
 * Normalizes processEntities option for backward compatibility
5✔
48
 * @param {boolean|object} value 
5✔
49
 * @returns {object} Always returns normalized object
5✔
50
 */
5✔
51
function normalizeProcessEntities(value) {
1,115✔
52
  // Boolean backward compatibility
1,115✔
53
  if (typeof value === 'boolean') {
1,115✔
54
    return {
1,000✔
55
      enabled: value, // true or false
1,000✔
56
      maxEntitySize: 10000,
1,000✔
57
      maxExpansionDepth: 10,
1,000✔
58
      maxTotalExpansions: 1000,
1,000✔
59
      maxExpandedLength: 100000,
1,000✔
60
      maxEntityCount: 100,
1,000✔
61
      allowedTags: null,
1,000✔
62
      tagFilter: null
1,000✔
63
    };
1,000✔
64
  }
1,000✔
65

115✔
66
  // Object config - merge with defaults
115✔
67
  if (typeof value === 'object' && value !== null) {
1,115✔
68
    return {
115✔
69
      enabled: value.enabled !== false, // default true if not specified
115✔
70
      maxEntitySize: value.maxEntitySize ?? 10000,
115✔
71
      maxExpansionDepth: value.maxExpansionDepth ?? 10,
115✔
72
      maxTotalExpansions: value.maxTotalExpansions ?? 1000,
115✔
73
      maxExpandedLength: value.maxExpandedLength ?? 100000,
115✔
74
      maxEntityCount: value.maxEntityCount ?? 100,
115✔
75
      allowedTags: value.allowedTags ?? null,
115✔
76
      tagFilter: value.tagFilter ?? null
115✔
77
    };
115✔
78
  }
115✔
79

×
80
  // Default to enabled with limits
×
81
  return normalizeProcessEntities(true);
×
82
}
1,115✔
83

5✔
84
export const buildOptions = function (options) {
5✔
85
  const built = Object.assign({}, defaultOptions, options);
1,115✔
86

1,115✔
87
  // Always normalize processEntities for backward compatibility and validation
1,115✔
88
  built.processEntities = normalizeProcessEntities(built.processEntities);
1,115✔
89

1,115✔
90
  // Convert old-style stopNodes for backward compatibility
1,115✔
91
  if (built.stopNodes && Array.isArray(built.stopNodes)) {
1,115✔
92
    built.stopNodes = built.stopNodes.map(node => {
1,115✔
93
      if (typeof node === 'string' && node.startsWith('*.')) {
265✔
94
        // Old syntax: *.tagname meant "tagname anywhere"
60✔
95
        // Convert to new syntax: ..tagname
60✔
96
        return '..' + node.substring(2);
60✔
97
      }
60✔
98
      return node;
205✔
99
    });
1,115✔
100
  }
1,115✔
101
  //console.debug(built.processEntities)
1,115✔
102
  return built;
1,115✔
103
};
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc