troy 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- troy (0.0.4)
4
+ troy (0.0.5)
5
5
  builder
6
6
  i18n
7
7
  rack
data/lib/troy/meta.rb CHANGED
@@ -20,7 +20,7 @@ module Troy
20
20
  end
21
21
 
22
22
  def method_missing(name, *args, &block)
23
- self[name]
23
+ data[name.to_s]
24
24
  end
25
25
 
26
26
  def respond_to_missing?(method, include_private = false)
data/lib/troy/server.rb CHANGED
@@ -25,12 +25,23 @@ module Troy
25
25
  [status, headers, content]
26
26
  end
27
27
 
28
+ def normalized_path
29
+ path = request.path.gsub(%r[/$], "")
30
+ path << "?#{request.query_string}" unless request.query_string.empty?
31
+ path
32
+ end
33
+
28
34
  def process
29
35
  path = request.path[%r[^/(.*?)/?$], 1]
30
36
  path = "index" if path == ""
31
37
  path = root.join(path)
32
38
 
33
- if (_path = Pathname.new("#{path}.html")).file?
39
+ if request.path != "/" && request.path.end_with?("/")
40
+ [301, {
41
+ "Content-Type" => "text/html",
42
+ "Location" => normalized_path
43
+ }, []]
44
+ elsif (_path = Pathname.new("#{path}.html")).file?
34
45
  render(200, "text/html", _path)
35
46
  elsif (_path = Pathname.new("#{path}.xml")).file?
36
47
  render(200, "text/xml", _path)
data/lib/troy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Troy
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: troy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: