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

UiPath / uipathcli / 14878614187

07 May 2025 08:13AM UTC coverage: 90.539% (+0.02%) from 90.523%
14878614187

Pull #191

github

thschmitt
Move URI formatting logic from plugins into UriBuilder

Each plugin has been doing some custom formatting of the URI and
replacing organization and tenant. Moved all the logic for URI handling
in the API clients which use the `uri_builder.go`.

Changed all the code which uses the baseUri to make use of url.URL
instead of strings which allowed removing the `NewUriBuilder` method
which used to convert the baseUri string.

Noticed that the UriBuilder does not espace all URI parts properly.
Added escaping for path and query string keys.

Added more tests to validate the url formatting to avoid similar issues
like https://github.com/UiPath/uipathcli/issues/189.
Pull Request #191: Move URI formatting logic from plugins into UriBuilder

160 of 163 new or added lines in 15 files covered. (98.16%)

1 existing line in 1 file now uncovered.

6421 of 7092 relevant lines covered (90.54%)

1.02 hits per line

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

91.67
/utils/converter/string_converter.go
1
// Package converter provides helper classes for transformating data
2
// from one representation to another.
3
package converter
4

5
import (
6
        "fmt"
7
        "strconv"
8
        "strings"
9
)
10

11
// StringConverter converts interface{} values into a string.
12
// Depending on the type of the parameter, it converts the value to
13
// the proper format:
14
// - Integers, Float, etc.. are simply converted to a string
15
// - Arrays are formatted comma-separated
16
// - Booleans are converted to true or false
17
type StringConverter struct{}
18

19
func (c StringConverter) ToString(value interface{}) string {
1✔
20
        switch value := value.(type) {
1✔
21
        case []int, []float64, []bool, []string:
1✔
22
                array := c.ToStringArray(value)
1✔
23
                return strings.Join(array, ",")
1✔
24
        case int:
1✔
25
                return strconv.Itoa(value)
1✔
26
        case float64:
1✔
27
                return strconv.FormatFloat(value, 'f', -1, 64)
1✔
28
        case bool:
1✔
29
                return strconv.FormatBool(value)
1✔
30
        case string:
1✔
31
                return value
1✔
NEW
32
        default:
×
NEW
33
                return fmt.Sprint(value)
×
34
        }
35
}
36

37
func (c StringConverter) ToStringArray(value interface{}) []string {
1✔
38
        switch value := value.(type) {
1✔
39
        case []int:
1✔
40
                return c.intArrayToStringArray(value)
1✔
41
        case []float64:
1✔
42
                return c.floatArrayToStringArray(value)
1✔
43
        case []bool:
1✔
44
                return c.boolArrayToStringArray(value)
1✔
45
        case []string:
1✔
46
                return value
1✔
UNCOV
47
        default:
×
NEW
48
                return strings.Fields(fmt.Sprint(value))
×
49
        }
50
}
51

52
func (c StringConverter) intArrayToStringArray(array []int) []string {
1✔
53
        result := make([]string, len(array))
1✔
54
        for i, value := range array {
2✔
55
                result[i] = strconv.Itoa(value)
1✔
56
        }
1✔
57
        return result
1✔
58
}
59

60
func (c StringConverter) floatArrayToStringArray(array []float64) []string {
1✔
61
        result := make([]string, len(array))
1✔
62
        for i, value := range array {
2✔
63
                result[i] = strconv.FormatFloat(value, 'f', -1, 64)
1✔
64
        }
1✔
65
        return result
1✔
66
}
67

68
func (c StringConverter) boolArrayToStringArray(array []bool) []string {
1✔
69
        result := make([]string, len(array))
1✔
70
        for i, value := range array {
2✔
71
                result[i] = strconv.FormatBool(value)
1✔
72
        }
1✔
73
        return result
1✔
74
}
75

76
func NewStringConverter() *StringConverter {
1✔
77
        return &StringConverter{}
1✔
78
}
1✔
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