Skip to content

Commit

Permalink
Improve list of JSON logic
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Jul 8, 2022
1 parent 488df56 commit c087df2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aws_policy_equivalence.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func PoliciesAreEquivalent(policy1, policy2 string) (bool, error) {
// policies, such as assume-role policies that can be lists of JSONs. This
// only handles a one-length list of JSON:
policy1 = strings.TrimSpace(policy1)
if strings.HasPrefix(policy1, "[") {
if strings.HasPrefix(policy1, "[") && strings.HasSuffix(policy1, "]") {
policy1 = strings.TrimPrefix(strings.TrimSuffix(policy1, "]"), "[")
if strings.TrimSpace(policy1) == "" {
policy1 = "{}"
}
}

policy2 = strings.TrimSpace(policy2)
if strings.HasPrefix(policy2, "[") {
if strings.HasPrefix(policy2, "[") && strings.HasSuffix(policy2, "]") {
policy2 = strings.TrimPrefix(strings.TrimSuffix(policy2, "]"), "[")
if strings.TrimSpace(policy2) == "" {
policy2 = "{}"
Expand Down

0 comments on commit c087df2

Please sign in to comment.