From 39897ac7e6adb887b5902842e206755c7d14abfa Mon Sep 17 00:00:00 2001 From: Matthew Keener Date: Fri, 19 May 2023 14:37:13 -0400 Subject: [PATCH] update: Changing returned match from m[1] to m[2] to handle the option of git-codecommit vs git-codecommit-fips --- pkg/awsv4/signer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/awsv4/signer.go b/pkg/awsv4/signer.go index aa63c37..dc1122d 100644 --- a/pkg/awsv4/signer.go +++ b/pkg/awsv4/signer.go @@ -38,6 +38,7 @@ import ( ) var ( + // urlRgx = regexp.MustCompile(`^https://git-codecommit\.(.*)\.(amazonaws\.com|amazonaws\.com\.cn)/v1/repos/.*$`) urlRgx = regexp.MustCompile(`^https://(git-codecommit|git-codecommit-fips)\.(.*)\.(amazonaws\.com|amazonaws\.com\.cn)/v1/repos/.*$`) ) @@ -92,7 +93,8 @@ func (s *Signer) Sign(cloneURL string) (string, error) { func identifyRegion(url string) (string, error) { if m := urlRgx.FindStringSubmatch(url); len(m) > 1 { - return m[1], nil + // return m[2], errors.New(fmt.Sprintf("found submatch: %s", m[2])) + return m[2], nil } return "", errors.New("no region found in malformed codecommit URL")