Skip to content

Commit 840951e

Browse files
committed
fix failed writing comments.json for utf-8 encoded characters
1 parent e414ac6 commit 840951e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
if req.request_method == 'POST'
2525
# Assume it's well formed
26-
comments << req.query
26+
comment = {}
27+
req.query.each do |key, value|
28+
comment[key] = value.force_encoding('UTF-8')
29+
end
30+
comments << comment
2731
File.write('./comments.json', JSON.pretty_generate(comments, :indent => ' '))
2832
end
2933

0 commit comments

Comments
 (0)