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

NaturalIntelligence / fast-xml-parser / 22607952071

03 Mar 2026 04:10AM UTC coverage: 97.689% (-0.2%) from 97.87%
22607952071

push

github

amitguptagwl
update release info

1029 of 1065 branches covered (96.62%)

8454 of 8654 relevant lines covered (97.69%)

515532.84 hits per line

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

96.67
/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,845✔
21
  },
5✔
22
  attributeValueProcessor: function (attrName, val) {
5✔
23
    return val;
1,155✔
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
4,395✔
38
  },
5✔
39
  // skipEmptyListItem: false
5✔
40
  captureMetaData: false,
5✔
41
  maxNestedTags: 100,
5✔
42
  strictReservedNames: true,
5✔
43
};
5✔
44

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

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

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

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

1,005✔
86
  // Always normalize processEntities for backward compatibility and validation
1,005✔
87
  built.processEntities = normalizeProcessEntities(built.processEntities);
1,005✔
88
  //console.debug(built.processEntities)
1,005✔
89
  return built;
1,005✔
90
};
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