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

fastify / busboy / 8076850476

28 Feb 2024 07:35AM UTC coverage: 95.407% (+0.01%) from 95.393%
8076850476

push

github

web-flow
fix: dont use internal _events attribute (#146)

487 of 530 branches covered (91.89%)

Branch coverage included in aggregate %.

780 of 798 relevant lines covered (97.74%)

156.79 hits per line

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

97.67
/lib/utils/Decoder.js
1
'use strict'
2

3
const RE_PLUS = /\+/g
6✔
4

5
const HEX = [
6✔
6
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
10
  0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12
  0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
14
]
15

16
function Decoder () {
17
  this.buffer = undefined
42✔
18
}
19
Decoder.prototype.write = function (str) {
6✔
20
  // Replace '+' with ' ' before decoding
21
  str = str.replace(RE_PLUS, ' ')
63✔
22
  let res = ''
63✔
23
  let i = 0; let p = 0; const len = str.length
63✔
24
  for (; i < len; ++i) {
63✔
25
    if (this.buffer !== undefined) {
343✔
26
      if (!HEX[str.charCodeAt(i)]) {
42✔
27
        res += '%' + this.buffer
2✔
28
        this.buffer = undefined
2✔
29
        --i // retry character
2✔
30
      } else {
31
        this.buffer += str[i]
40✔
32
        ++p
40✔
33
        if (this.buffer.length === 2) {
40✔
34
          res += String.fromCharCode(parseInt(this.buffer, 16))
19✔
35
          this.buffer = undefined
19✔
36
        }
37
      }
38
    } else if (str[i] === '%') {
301✔
39
      if (i > p) {
22!
40
        res += str.substring(p, i)
22✔
41
        p = i
22✔
42
      }
43
      this.buffer = ''
22✔
44
      ++p
22✔
45
    }
46
  }
47
  if (p < len && this.buffer === undefined) { res += str.substring(p) }
63✔
48
  return res
63✔
49
}
50
Decoder.prototype.reset = function () {
6✔
51
  this.buffer = undefined
45✔
52
}
53

54
module.exports = Decoder
6✔
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