@@ -13,13 +13,16 @@ func WorkspaceSearchQuery(query string) (map[string]string, error) {
13
13
if query == "" {
14
14
return searchParams , nil
15
15
}
16
- elements := splitElements (query , ' ' )
16
+ // Because we do this in 2 passes, we want to maintain quotes on the first
17
+ // pass.Further splitting occurs on the second pass and quotes will be
18
+ // dropped.
19
+ elements := splitElements (query , ' ' , true )
17
20
for _ , element := range elements {
18
- parts := splitElements (query , ':' )
21
+ parts := splitElements (element , ':' , false )
19
22
switch len (parts ) {
20
23
case 1 :
21
24
// No key:value pair. It is a workspace name, and maybe includes an owner
22
- parts = splitElements (query , '/' )
25
+ parts = splitElements (element , '/' , false )
23
26
switch len (parts ) {
24
27
case 1 :
25
28
searchParams ["name" ] = parts [0 ]
@@ -48,14 +51,17 @@ func WorkspaceSearchQuery(query string) (map[string]string, error) {
48
51
// can properly fail on the space. If we do not, a value of `template:"my name"`
49
52
// will search `template:"my name:name"`, which produces an empty list instead of
50
53
// an error.
51
- func splitElements (query string , delimiter rune ) []string {
54
+ func splitElements (query string , delimiter rune , maintainQuotes bool ) []string {
52
55
var parts []string
53
56
54
57
quoted := false
55
58
var current strings.Builder
56
59
for _ , c := range query {
57
60
switch c {
58
61
case '"' :
62
+ if maintainQuotes {
63
+ _ , _ = current .WriteRune (c )
64
+ }
59
65
quoted = ! quoted
60
66
case delimiter :
61
67
if quoted {
0 commit comments