Skip to content

Commit

Permalink
🚨 fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pikachu0310 committed Sep 26, 2024
1 parent 20e3dd1 commit 1c5ee77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions grpc/federation/cel/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cel

import (
"context"
"net/url"

"github.com/google/cel-go/cel"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/common/types/traits"
"net/url"
)

const URLPackageName = "url"
Expand Down Expand Up @@ -381,6 +382,9 @@ func (lib *URLLibrary) CompileOptions() []cel.EnvOption {
}

v.Path, err = url.JoinPath(v.Path, paths...)
if err != nil {
return types.NewErr(err.Error())
}

return lib.toURLValue(v)
},
Expand Down Expand Up @@ -448,10 +452,6 @@ func (lib *URLLibrary) CompileOptions() []cel.EnvOption {
queryParams := v.Query()
queryMap := map[ref.Val]ref.Val{}
for key, values := range queryParams {
var valueList []ref.Val
for _, val := range values {
valueList = append(valueList, types.String(val))
}
queryMap[types.String(key)] = types.NewStringList(adapter, values)
}

Expand Down
7 changes: 4 additions & 3 deletions grpc/federation/cel/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package cel_test
import (
"context"
"fmt"
"github.com/google/cel-go/common/types/traits"
"github.com/google/go-cmp/cmp/cmpopts"
"net/url"
"strings"
"testing"

"github.com/google/cel-go/cel"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/common/types/traits"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

cellib "github.com/mercari/grpc-federation/grpc/federation/cel"
)

Expand Down Expand Up @@ -425,7 +426,7 @@ func TestURLFunctions(t *testing.T) {
},
},
{
name: "join path",
name: "url join path",
expr: `grpc.federation.url.parse('https://example.com/path?query=1#fragment').joinPath(['/new'])`,
cmp: func(got ref.Val) error {
gotV, ok := got.Value().(*cellib.URL)
Expand Down

0 comments on commit 1c5ee77

Please sign in to comment.