Skip to content

Commit

Permalink
Allow single character strings in azure_rm_api_management_api Path va…
Browse files Browse the repository at this point in the history
…riable validation (#26922)

* Allow single character strings in APIM API Path validation

* Fix issue in regex for allowing single character strings in APIM API Path validation
  • Loading branch information
Lakshan-Banneheke authored Aug 16, 2024
1 parent 916eec2 commit c1c46f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/services/apimanagement/validate/api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func ApiManagementApiName(v interface{}, k string) (ws []string, es []error) {
func ApiManagementApiPath(v interface{}, k string) (ws []string, es []error) {
value := v.(string)

if matched := regexp.MustCompile(`^(?:|[\w.][\w-/.:]{0,398}[\w-])$`).Match([]byte(value)); !matched {
if matched := regexp.MustCompile(`^(?:|[\w]|[\w.][\w-/.:]{0,398}[\w-])$`).Match([]byte(value)); !matched {
es = append(es, fmt.Errorf("%q may only be up to 400 characters in length, not start or end with `/` and only contain valid url characters", k))
}
return ws, es
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func TestAzureRMApiManagementApiPath_validation(t *testing.T) {
Value: "api1:sub",
ErrCount: 0,
},
{
Value: "a",
ErrCount: 0,
},
{
Value: s.Repeat("x", 401),
ErrCount: 1,
Expand Down

0 comments on commit c1c46f4

Please sign in to comment.