Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions controller/pkg/agentgateway/translator/agw.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ func CreateAgwPathMatch(match gwv1.HTTPRouteMatch) (*api.PathMatch, *reporter.Ro
if match.Path.Type != nil {
tp = *match.Path.Type
}
// Path value must start with "/". If empty/nil, coerce to "/".
// For non-regex path match types, ensure the path starts with "/".
// If the value is empty or nil, default to "/".
// RegularExpression paths are not modified to support full regex patterns (e.g. "^/.*$").
dest := "/"
if match.Path.Value != nil && *match.Path.Value != "" {
dest = *match.Path.Value
}
if !strings.HasPrefix(dest, "/") {
dest = "/" + dest
if tp != gwv1.PathMatchRegularExpression {
if !strings.HasPrefix(dest, "/") {
dest = "/" + dest
}
}
switch tp {
case gwv1.PathMatchPathPrefix:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
Comment on lines +1 to +3
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case exercises path.type: RegularExpression, but the filename suggests a PathPrefix match. Consider renaming the file (and any references, if applicable) to avoid confusion when scanning route test coverage.

Copilot uses AI. Check for mistakes.
name: regex-route
namespace: default
spec:
parentRefs:
- name: test-gateway
hostnames:
- example.com
rules:
- matches:
- path:
type: RegularExpression
value: ^/.*$
backendRefs:
- name: test-service
port: 80
---
# Output
output:
- gateway:
Name: test-gateway
Namespace: default
resource:
route:
backends:
- backend:
port: 80
service:
hostname: test-service.default.svc.cluster.local
namespace: default
weight: 1
hostnames:
- example.com
key: default/regex-route.00.http
listenerKey: default/test-gateway.http
matches:
- path:
regex: ^/.*$
name:
kind: HTTPRoute
name: regex-route
namespace: default
status:
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: regex-route
namespace: default
spec: null
status:
parents:
- conditions:
- lastTransitionTime: fake
message: ""
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: fake
message: ""
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: agentgateway.dev/agentgateway
parentRef:
group: gateway.networking.k8s.io
kind: Gateway
name: test-gateway
namespace: default