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

supabase / storage / 22763435164

06 Mar 2026 12:27PM UTC coverage: 76.221% (+0.1%) from 76.093%
22763435164

push

github

web-flow
fix: improve biome lint configuration (#892)

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

3992 of 5697 branches covered (70.07%)

Branch coverage included in aggregate %.

46 of 69 new or added lines in 12 files covered. (66.67%)

76 existing lines in 8 files now uncovered.

26757 of 34645 relevant lines covered (77.23%)

187.37 hits per line

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

79.31
/src/http/plugins/xml.ts
1
import accepts from '@fastify/accepts'
2✔
2
import { FastifyInstance } from 'fastify'
2✔
3
import fastifyPlugin from 'fastify-plugin'
2✔
4
import xml from 'xml2js'
2✔
5

2✔
6
type XmlParserOptions = { disableContentParser?: boolean; parseAsArray?: string[] }
2✔
7
type RequestError = Error & { statusCode?: number }
2✔
8

2✔
9
function forcePathAsArray(node: unknown, pathSegments: string[]): void {
4✔
10
  if (pathSegments.length === 0 || node === null || node === undefined) {
4!
UNCOV
11
    return
×
UNCOV
12
  }
×
13

4✔
14
  if (Array.isArray(node)) {
4!
UNCOV
15
    node.forEach((item) => forcePathAsArray(item, pathSegments))
×
UNCOV
16
    return
×
UNCOV
17
  }
×
18

4✔
19
  if (typeof node !== 'object') {
4!
UNCOV
20
    return
×
UNCOV
21
  }
×
22

4✔
23
  const [current, ...rest] = pathSegments
4✔
24
  const currentRecord = node as Record<string, unknown>
4✔
25

4✔
26
  if (!(current in currentRecord)) {
4!
UNCOV
27
    return
×
UNCOV
28
  }
×
29

4✔
30
  if (rest.length === 0) {
4✔
31
    const value = currentRecord[current]
2✔
32
    if (value !== undefined && !Array.isArray(value)) {
2✔
33
      currentRecord[current] = [value]
2✔
34
    }
2✔
35
    return
2✔
36
  }
2✔
37

2✔
38
  forcePathAsArray(currentRecord[current], rest)
2✔
39
}
2✔
40

2✔
41
export const xmlParser = fastifyPlugin(
2✔
42
  async function (fastify: FastifyInstance, opts: XmlParserOptions) {
2✔
43
    fastify.register(accepts)
2,882✔
44

2,882✔
45
    if (!opts.disableContentParser) {
2,882✔
46
      fastify.addContentTypeParser(
2,620✔
47
        ['text/xml', 'application/xml'],
2,620✔
48
        { parseAs: 'string' },
2,620✔
49
        (_request, body, done) => {
2,620✔
50
          if (!body) {
4!
UNCOV
51
            done(null, null)
×
UNCOV
52
            return
×
UNCOV
53
          }
×
54

4✔
55
          xml.parseString(
4✔
56
            body,
4✔
57
            {
4✔
58
              explicitArray: false,
4✔
59
              trim: true,
4✔
60
              valueProcessors: [xml.processors.parseNumbers, xml.processors.parseBooleans],
4✔
61
            },
4✔
62
            (err: Error | null, parsed: unknown) => {
4✔
63
              if (err) {
4✔
64
                const parseError: RequestError = new Error(`Invalid XML payload: ${err.message}`)
2✔
65
                parseError.statusCode = 400
2✔
66
                done(parseError)
2✔
67
                return
2✔
68
              }
2✔
69

2✔
70
              if (parsed && opts.parseAsArray?.length) {
4✔
71
                opts.parseAsArray.forEach((path) => {
2✔
72
                  if (!path) {
2!
UNCOV
73
                    return
×
UNCOV
74
                  }
×
75
                  forcePathAsArray(parsed, path.split('.'))
2✔
76
                })
2✔
77
              }
2✔
78

2✔
79
              done(null, parsed)
2✔
80
            }
2✔
81
          )
4✔
82
        }
4✔
83
      )
2,620✔
84
    }
2,620✔
85

2,882✔
86
    fastify.addHook('preSerialization', async (req, res, payload) => {
2,882✔
87
      const accept = req.accepts()
2✔
88

2✔
89
      const acceptedTypes = ['application/xml', 'text/html']
2✔
90

2✔
91
      if (acceptedTypes.some((allowed) => accept.types(acceptedTypes) === allowed)) {
2✔
92
        res.serializer((payload) => payload)
2✔
93

2✔
94
        const xmlBuilder = new xml.Builder({
2✔
95
          renderOpts: {
2✔
96
            pretty: false,
2✔
97
          },
2✔
98
        })
2✔
99
        const xmlPayload = xmlBuilder.buildObject(payload)
2✔
100
        res.type('application/xml')
2✔
101
        res.header('content-type', 'application/xml; charset=utf-8')
2✔
102
        return xmlPayload
2✔
103
      }
2✔
UNCOV
104

×
UNCOV
105
      return payload
×
106
    })
2,882✔
107
  },
2,882✔
108
  { name: 'xml-parser' }
2✔
109
)
2✔
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