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

visgl / loaders.gl / 24153816851

08 Apr 2026 07:17PM UTC coverage: 53.247% (-12.1%) from 65.319%
24153816851

push

github

web-flow
chore: Move from tape to vitest (#3351)

8651 of 17291 branches covered (50.03%)

Branch coverage included in aggregate %.

7 of 7 new or added lines in 1 file covered. (100.0%)

2031 existing lines in 296 files now uncovered.

17563 of 31940 relevant lines covered (54.99%)

5279.54 hits per line

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

66.67
/modules/xml/src/html-loader.ts
1
// loaders.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
6
import {mergeOptions} from '@loaders.gl/loader-utils';
7
import {XMLLoader, XMLLoaderOptions} from './xml-loader';
8

9
export type HTMLLoaderOptions = XMLLoaderOptions;
10

11
/**
12
 * Loader for HTML files
13
 * Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.
14
 * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.
15
 * This loader does not have any additional understanding of the structure of HTML or the document.
16
 */
17
export const HTMLLoader = {
63✔
18
  ...XMLLoader,
19
  name: 'HTML',
20
  id: 'html',
21
  extensions: ['html', 'htm'],
22
  mimeTypes: ['text/html'],
23
  testText: testHTMLFile,
24
  parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>
UNCOV
25
    parseTextSync(new TextDecoder().decode(arrayBuffer), options),
×
26
  parseTextSync: (text: string, options?: XMLLoaderOptions) => parseTextSync(text, options)
1✔
27
} as const satisfies LoaderWithParser<any, never, HTMLLoaderOptions>;
28

29
function testHTMLFile(text: string): boolean {
30
  // TODO - There could be space first.
31
  return text.startsWith('<html');
×
32
}
33

34
function parseTextSync(text: string, options?: XMLLoaderOptions): any {
35
  // fast-xml-parser can recognize HTML entities
36
  // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities
37
  // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md
38
  options = mergeOptions(options, {
1✔
39
    xml: {
40
      _parser: 'fast-xml-parser',
41
      _fastXML: {
42
        htmlEntities: true
43
      }
44
    }
45
  });
46

47
  return XMLLoader.parseTextSync?.(text, options);
1✔
48
}
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