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 +1 -1
- data/lib/troy/meta.rb +1 -1
- data/lib/troy/server.rb +12 -1
- data/lib/troy/version.rb +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/troy/meta.rb
CHANGED
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
|
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