enconverter 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{enconverter}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jinzhu"]
@@ -19,7 +19,7 @@ module Rack
19
19
  if convert && [nil, "text/html", "application/xhtml+xml"].include?(header[:content_type]) && response.respond_to?(:body)
20
20
  type, charset = header['Content-Type'].split(/;\s*charset=/)
21
21
  response.body = process_body(response.body)
22
- header['Content-Type'] = "#{type}; charset=shift-jis"
22
+ header['Content-Type'] = "#{type}; charset=shift_jis"
23
23
  end
24
24
 
25
25
  [status, header, response]
@@ -28,13 +28,13 @@ module Rack
28
28
  private
29
29
  def process_body(body)
30
30
  body_doc = Nokogiri::HTML(body)
31
- body_doc.meta_encoding = 'shift-jis'
31
+ body_doc.meta_encoding = 'shift_jis'
32
32
  body_doc.search('meta[@http-equiv="Content-Type"]').map do |e|
33
- e["content"] = e["content"].sub(/utf-?8/,'shift-jis')
33
+ e["content"] = e["content"].sub(/utf-?8/,'shift_jis')
34
34
  end
35
35
 
36
36
  body = body_doc.to_html
37
- Iconv.conv('shift-jis//IGNORE','utf-8', body)
37
+ Iconv.conv('shift_jis//IGNORE','utf-8', body).sub(/charset=utf-?8/,'charset=shift_jis')
38
38
  end
39
39
 
40
40
  def scrub(env)
@@ -57,7 +57,7 @@ module Rack
57
57
  end
58
58
 
59
59
  def convert_japanese(str)
60
- Iconv.conv('utf-8//IGNORE','shift-jis', str)
60
+ Iconv.conv('utf-8//IGNORE','shift_jis', str)
61
61
  end
62
62
  end
63
63
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enconverter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jinzhu