syntropy 0.27.5 → 0.27.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5c258eb1b8a3c19dc13f545ffe5af87763e48d461d96dd9c3a1d11aa211ccf7
4
- data.tar.gz: 0cf9bb42be816f61316084483284417f13e07a17771a3c4ea3ad23e34df8f30a
3
+ metadata.gz: 7e8df1d7aac0cc40148bec47ea488aac153a10a120e1bb3c2f8233bbf5a1cb61
4
+ data.tar.gz: 7654c5548f51b040ea7ca6e52bb522f83e0117717c0d1e29ad8cd20dc7e8c857
5
5
  SHA512:
6
- metadata.gz: 82e2c6c9e36b63baa98a3bf31de19c543e9f748a2b1b636146bc12c4525a61df2acc5f605b787677967f679b5a39cdfdf7c0b13a97f6317797e8c1fac3fca657
7
- data.tar.gz: fc27a9f9a452420a265e9f00261be025e70b8f47e97d21055706533bc543906ba74c43ddbd8903da1637ff8a3b46f6f89aabeaf07787537ef1a31bd30e6ce1c7
6
+ metadata.gz: 1a522e390af9b35866b2fe9837a084d330ab42bef82b629978ed070e58353fc326a5380e4ffebb378d2ac2e27d18930be6eb3a65e74df3d1eebf12ff528d7f8b
7
+ data.tar.gz: cdb0757c9a15cc285fb2900e695327da175712f92acbde2452c1c7d12a63f06f1d6223d642e836c1d0d673f4ee11d5bf16837dc3b06f5dd2e1340bbf9320e228
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.27.6 2025-10-30
2
+
3
+ - Redirect automatically on trailing slash
4
+
1
5
  # 0.27.5 2025-10-28
2
6
 
3
7
  - Update Papercraft
data/lib/syntropy/app.rb CHANGED
@@ -64,8 +64,14 @@ module Syntropy
64
64
  # @param req [Qeweney::Request] HTTP request
65
65
  # @return [void]
66
66
  def call(req)
67
- route = @router_proc.(req.path, req.route_params)
68
- raise Syntropy::Error.not_found('Not found') if !route
67
+ path = req.path
68
+ route = @router_proc.(path, req.route_params)
69
+ if !route
70
+ if (m = path.match(/^(.+)\/$/))
71
+ return req.redirect(m[1], Qeweney::Status::MOVED_PERMANENTLY)
72
+ end
73
+ raise Syntropy::Error.not_found('Not found')
74
+ end
69
75
 
70
76
  req.route = route
71
77
  proc = route[:proc] ||= compute_route_proc(route)
@@ -74,7 +80,7 @@ module Syntropy
74
80
  @logger&.error(
75
81
  message: "Error while serving request: #{e.message}",
76
82
  method: req.method,
77
- path: req.path,
83
+ path: path,
78
84
  error: e
79
85
  ) if Error.log_error?(e)
80
86
  error_handler = get_error_handler(route)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Syntropy
4
- VERSION = '0.27.5'
4
+ VERSION = '0.27.6'
5
5
  end
data/test/test_app.rb CHANGED
@@ -122,6 +122,12 @@ class AppTest < Minitest::Test
122
122
  assert_equal Status::INTERNAL_SERVER_ERROR, req.response_status
123
123
  end
124
124
 
125
+ def test_automatic_redirect_on_trailing_slash
126
+ req = make_request(':method' => 'GET', ':path' => '/test/rss/')
127
+ assert_equal Status::MOVED_PERMANENTLY, req.response_status
128
+ assert_equal '/test/rss', req.response_headers['Location']
129
+ end
130
+
125
131
  def test_app_file_watching
126
132
  @machine.sleep 0.3
127
133
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntropy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.5
4
+ version: 0.27.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner