Skip to content

Commit

Permalink
fix: add blank lines to empty hashs - json 2.8.x regression for pact-…
Browse files Browse the repository at this point in the history
…ruby
  • Loading branch information
YOU54F committed Nov 29, 2024
1 parent df97a7d commit d06a535
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/pact/shared/active_support_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ def fix_regexp regexp
# Oh ActiveSupport, why....
def fix_json_formatting json
if json =~ /\{".*?":"/
JSON.pretty_generate(JSON.parse(json, create_additions: false))
json = JSON.pretty_generate(JSON.parse(json, create_additions: false))
else
json
end
fix_empty_hash_and_array json
end

def remove_unicode json
Expand All @@ -61,5 +62,13 @@ def warn_about_regexp(thing)
end
end
end

private

def fix_empty_hash_and_array json
json = json.gsub(/({\s*})/, "{\n }")
json.gsub(/\[\s*\]/, "[\n ]")
json
end
end
end

0 comments on commit d06a535

Please sign in to comment.