rack-musicindex 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,11 +17,14 @@ module Rack
17
17
  def call(env)
18
18
  path_info = env['PATH_INFO']
19
19
 
20
+ # to compare with static_path which is utf-8 encoding
21
+ path_info.force_encoding('UTF-8') if path_info.respond_to? :force_encoding
22
+
20
23
  update_files
21
24
 
22
25
  if dirs[path_info]
23
26
  serve_podcast(env)
24
- elsif static_paths.include?(URI.unescape(path_info))
27
+ elsif static_paths.include?(unescape(path_info))
25
28
  serve_mp3(env)
26
29
  else
27
30
  status, headers, response = @app.call(env)
@@ -46,7 +49,7 @@ module Rack
46
49
  status, headers, response = @app.call(env)
47
50
 
48
51
  method = env['REQUEST_METHOD']
49
- path_info = URI.unescape(env['PATH_INFO'])
52
+ path_info = unescape(env['PATH_INFO'])
50
53
  body = open(static_paths[path_info], 'rb').read
51
54
 
52
55
  headers["Content-Type"] = 'audio/mpeg'
@@ -120,7 +123,7 @@ module Rack
120
123
  tag = id3(file)
121
124
  author = tag[:artist]
122
125
  name = ::File.basename(file)
123
- item_link = URI.escape(url + '/' + name)
126
+ item_link = escape(url + '/' + name)
124
127
 
125
128
  xml.item do
126
129
  xml.title tag[:name] || name
@@ -138,5 +141,13 @@ module Rack
138
141
  end
139
142
  end
140
143
  end
144
+
145
+ def escape(str)
146
+ URI.escape(str)
147
+ end
148
+
149
+ def unescape(str)
150
+ URI.unescape(str)
151
+ end
141
152
  end
142
153
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Musicindex
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-musicindex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -158,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  segments:
160
160
  - 0
161
- hash: -1489195418899785487
161
+ hash: -2682868914744133588
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements:
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  segments:
169
169
  - 0
170
- hash: -1489195418899785487
170
+ hash: -2682868914744133588
171
171
  requirements: []
172
172
  rubyforge_project:
173
173
  rubygems_version: 1.8.24