Skip to content

Commit

Permalink
operator: escape dots in url (#2990)
Browse files Browse the repository at this point in the history
  • Loading branch information
3u13r authored Mar 15, 2024
1 parent c40e1a9 commit 0b13c5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
)

var (
diskSourceRegex = regexp.MustCompile(`^https://www.googleapis.com/compute/v1/projects/([^/]+)/zones/([^/]+)/disks/([^/]+)$`)
computeAPIBase = regexp.MustCompile(`^https://www.googleapis.com/compute/v1/(.+)$`)
diskSourceRegex = regexp.MustCompile(`^https://www\.googleapis\.com/compute/v1/projects/([^/]+)/zones/([^/]+)/disks/([^/]+)$`)
computeAPIBase = regexp.MustCompile(`^https://www\.googleapis\.com/compute/v1/(.+)$`)
)

// diskSourceToDiskReq converts a disk source URI to a disk request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func TestDiskSourceToDiskReq(t *testing.T) {
diskSource: "invalid://www.googleapis.com/compute/v1/projects/project/zones/zone/disks/disk",
wantErr: true,
},
"url dots in regex are escaped": {
diskSource: "https://wwwAgoogleapisAcom/compute/v1/projects/project/zones/zone/disks/disk",
wantErr: true,
},
}

for name, tc := range testCases {
Expand Down Expand Up @@ -67,6 +71,10 @@ func TestURINormalize(t *testing.T) {
imageURI: "projects/project/global/images/image",
wantNormalized: "projects/project/global/images/image",
},
"url dots in regex are escaped": {
imageURI: "https://wwwAgoogleapisAcom/compute/v1/projects/project/global/images/image",
wantNormalized: "https://wwwAgoogleapisAcom/compute/v1/projects/project/global/images/image",
},
}

for name, tc := range testCases {
Expand Down

0 comments on commit 0b13c5b

Please sign in to comment.