sdoc_live 0.1.7 → 0.1.8
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.
- checksums.yaml +4 -4
- data/lib/sdoc_live/engine.rb +21 -11
- data/lib/sdoc_live/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c58eaf82f18b4feb7c431156e8ba8be018e22eb57b8b62d69e0e0c503e2085c
|
|
4
|
+
data.tar.gz: 372965feda50bdc4bc08b196d3acbbc43af6fe2b7fb4461b622bbb4f80c0befa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 224cc2e187603628bb1e76664ef87ff8f6c33640d34512d38e7f262b1e96490a3e05dc07ed2cc08f78e372adf8a016bae6c55199f2a9de3c57ebbcc1ea2e5bfb
|
|
7
|
+
data.tar.gz: dc1222d122c5992e1e9505e752305a28b164b0d55dff3bbdc3f3b19aae4d630c76d6940be15fd45201426e1c548172bea7722b61cf6f3f95eb4ffec2ef02c2f2
|
data/lib/sdoc_live/engine.rb
CHANGED
|
@@ -21,20 +21,30 @@ module SdocLive
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
initializer "sdoc_live.trailing_slash" do
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
initializer "sdoc_live.trailing_slash", after: :add_routing_paths do |app|
|
|
25
|
+
mount_path = nil
|
|
26
|
+
|
|
27
|
+
app.routes.routes.each do |route|
|
|
28
|
+
if route.app.respond_to?(:app) && route.app.app == SdocLive::Engine
|
|
29
|
+
mount_path = route.path.spec.to_s.gsub("(.:format)", "").chomp("/")
|
|
30
|
+
break
|
|
28
31
|
end
|
|
32
|
+
end
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
if mount_path && !mount_path.empty?
|
|
35
|
+
app.middleware.use(Class.new do
|
|
36
|
+
define_method(:initialize) { |a| @app = a }
|
|
37
|
+
|
|
38
|
+
define_method(:call) do |env|
|
|
39
|
+
if env["PATH_INFO"] == mount_path && !env["PATH_INFO"].end_with?("/")
|
|
40
|
+
query = env["QUERY_STRING"].to_s.empty? ? "" : "?#{ env['QUERY_STRING'] }"
|
|
41
|
+
[301, { "location" => "#{ mount_path }/#{ query }", "content-type" => "text/html" }, ["Redirecting..."]]
|
|
42
|
+
else
|
|
43
|
+
@app.call(env)
|
|
44
|
+
end
|
|
35
45
|
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
46
|
+
end)
|
|
47
|
+
end
|
|
38
48
|
end
|
|
39
49
|
|
|
40
50
|
end
|
data/lib/sdoc_live/version.rb
CHANGED