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

stackpress / lib / 15067526568

16 May 2025 11:34AM UTC coverage: 79.037% (-6.1%) from 85.102%
15067526568

push

github

cblanquera
terminal tests and fixes

482 of 670 branches covered (71.94%)

Branch coverage included in aggregate %.

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

51 existing lines in 10 files now uncovered.

913 of 1095 relevant lines covered (83.38%)

27.57 hits per line

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

93.88
/src/data/processors/QueryString.ts
1
//data
2
import type Nest from '../Nest.js';
3

4
export default class QueryString {
5
  /**
6
   * The main nest
7
   */
8
  public nest: Nest;
9

10
  /**
11
   * Sets the nest 
12
   */
13
  constructor(nest: Nest) {
14
    this.nest = nest;
176✔
15
  }
16

17
  /**
18
   * Creates the name space given the space
19
   * and sets the value to that name space
20
   */
21
  set(...path: any[]): Nest {
22
    if (path.length < 1) {
43✔
23
      return this.nest;
2✔
24
    }
25

26
    const query = path.pop();
41✔
27

28
    const separator = '~~' + Math.floor(Math.random() * 10000) + '~~';
41✔
29
    query.split(/\&/gi).forEach((filter: any) => {
41✔
30
      //key eg. foo[bar][][baz]
31
      let [ key, ...values ] = filter.split('=');
134✔
32
      let value = values.join('=');
134✔
33
      key = decodeURIComponent(key);
134✔
34
      value = value.replace(/\+/g, ' ');
134✔
35
      value = decodeURIComponent(value);
134✔
36
      //change path to N notation
37
      //ex. foo[bar][][baz]
38
      const keys = key
134✔
39
        //to. foo[bar~~123~~~~123~~baz]
40
        .replace(/\]\[/g, separator)
41
        //to. foo~~123~~bar~~123~~~~123~~baz]
42
        .replace('[', separator)
43
        //to. foo~~123~~bar~~123~~~~123~~baz
44
        .replace(/\[/g, '')
45
        .replace(/\]/g, '')
46
        //to. foo,bar,,baz
47
        .split(separator)
48
        .map((key: any) => {
49
          const index = Number(key);
244✔
50
          //if its a possible integer
51
          if (key && !isNaN(index) && key.indexOf('.') === -1) {
244✔
52
            return index;
27✔
53
          }
54

55
          return key;
217✔
56
        });
57

58
      const paths = path.concat(keys);
134✔
59

60
      if (/(^\{.*\}$)|(^\[.*\]$)/.test(value)) {
134!
61
        try {
×
UNCOV
62
          return query.set(...paths, JSON.parse(value));
×
63
        } catch(e) {}
64
      }
65

66
      if (value.length > 0 && !isNaN(Number(value))) {
134✔
67
        this.nest.set(...paths, Number(value));
25✔
68
      } else if (value === 'true') {
109✔
69
        this.nest.set(...paths, true);
23✔
70
      } else if (value === 'false') {
86✔
71
        this.nest.set(...paths, false);
13✔
72
      } else if (value === 'null') {
73✔
73
        this.nest.set(...paths, null);
13✔
74
      } else {
75
        this.nest.set(...paths, value);
60✔
76
      }
77
    });
78

79
    return this.nest;
41✔
80
  }
81
}
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