flame 4.9.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 765731c4ac1b82c375236c1aea949533956027cb
4
- data.tar.gz: fe2444302d7243844af734698540402e82230ccd
3
+ metadata.gz: 8395ff4675716dc3fb9aa3aa58b997624ca10d57
4
+ data.tar.gz: c612ae674eeb4571b71f42fcb39e60ccc8fc4f1f
5
5
  SHA512:
6
- metadata.gz: b35c4109bdca5cd8e7d65e88b2b541d65caa833f7f77647aeba5318cc6f35baec33cafc27d097e812a44b6d83032a7185db5dd5898db58783dadc6d4e4e85948
7
- data.tar.gz: fe7d7eaaad332bd3076fc6f78000140b1144df3f09551910b53bd9bce86d180c3be775146bacc01ece2d792d6f776376e681ef92b9fdac1a87209d9cd19683f9
6
+ metadata.gz: 639a69107187f6e64953d34c99abf822058c35ec320db0f0f54d84692f0810070825eec83bfeec11276e84e5f506277fa517d6f3a93a5e04bcfe08b684ecdd51
7
+ data.tar.gz: eed88fd30af185d4590519ad5e817744287082e7bedbb23de02c33662f3cc0b075d71b48a0d5c59300e81495036ba544b62eb6d1191a7f3755b44e7d592dac39
@@ -25,7 +25,8 @@ module Flame
25
25
  ## Start of execution the request
26
26
  def run!
27
27
  catch :halt do
28
- try_route ||
28
+ try_fix_slashes ||
29
+ try_route ||
29
30
  try_static ||
30
31
  try_static(File.join(__dir__, '..', '..', 'public')) ||
31
32
  halt(404)
@@ -145,6 +146,12 @@ module Flame
145
146
 
146
147
  private
147
148
 
149
+ ## Redirect from urls endings by slashes to same url without slashes
150
+ def try_fix_slashes
151
+ return if request.fullpath == request.fullpath_without_trailing_slashes
152
+ response.redirect(request.fullpath_without_trailing_slashes, 301)
153
+ end
154
+
148
155
  ## Find route and try execute it
149
156
  def try_route
150
157
  route = @app.class.router.find_route(
@@ -10,5 +10,10 @@ module Flame
10
10
  def http_method
11
11
  params['_method'] || request_method
12
12
  end
13
+
14
+ ## Return fullpath without trailing slashes
15
+ def fullpath_without_trailing_slashes
16
+ fullpath.gsub(%r{(?<=.)\/+(?=$|\?)}, '')
17
+ end
13
18
  end
14
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flame
4
- VERSION = '4.9.0'.freeze
4
+ VERSION = '4.10.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flame
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.9.0
4
+ version: 4.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov