hanami-router 2.0.0.alpha2 → 2.0.0.alpha3

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
  SHA256:
3
- metadata.gz: '078b6fde8c274fe1d60ae480f8b9aec21e3c765daf8ba58f10b1b30a2d0c2135'
4
- data.tar.gz: 941ad1968db99f130f18ef37ba12798e882e80b84aeb9974780edeabd446dcfb
3
+ metadata.gz: fab23d35a0e2c1e71ec08a112f95f35a2c21eed5fb3ab45f231a2a7fc500cc31
4
+ data.tar.gz: 85c7e6ab36e321fb04235f088f3f479f542e98cf00e5ae7d642bb323bb42d969
5
5
  SHA512:
6
- metadata.gz: 9091771edcea709bf395654175c7a4f8c1f961d85d66f553db6591d7e1c6675cea38cfdc393e5438e219edb75c75965d4a37727e2da69cdbe1d57ce6756523b7
7
- data.tar.gz: 130e577dd27732b4b74acc147a9fbaa444b682546092acd6ed849347c94edcbd779193917b66f4444dd4faf1d7f35ae5dc6755eada2b783ba5d62aa0b7d9c004
6
+ metadata.gz: 2ce90e7659b29b0571742eb972442ea27a4d51d1ea5500f9d25f943fe7e6a5e9b04598a1289a4c50f107289ea7162708a78e4825564b4ef056ee30a5765a63d6
7
+ data.tar.gz: b953c5d251e8cfb6f698bb6cea77df0dec2ff194bf51fe091d7fb4464ffad135c0760d328f9e50ae49f6cd48c45171b6ef4c55dc42f64c924cfd6d631cde5250
@@ -1,6 +1,12 @@
1
1
  # Hanami::Router
2
2
  Rack compatible HTTP router for Ruby
3
3
 
4
+ ## v2.0.0.alpha3 - 2020-05-20
5
+ ### Fixed
6
+ - [Luca Guidi] `Hanami::Router#initialize` do not yield block if not given
7
+ - [Luca Guidi] Ensure to not accidentally cache response headers for HTTP 404 and 405
8
+ - [Luca Guidi] Ensure scoped root to not be added as trailing slash
9
+
4
10
  ## v2.0.0.alpha2 - 2020-02-19
5
11
  ### Added
6
12
  - [Luca Guidi] Block syntax. Routes definition accept a block which returning value is the body of the Rack response.
@@ -71,7 +71,7 @@ module Hanami
71
71
  @variable = {}
72
72
  @globbed = {}
73
73
  @mounted = {}
74
- instance_eval(&blk)
74
+ instance_eval(&blk) if blk
75
75
  end
76
76
 
77
77
  # Resolve the given Rack env to a registered endpoint and invokes it.
@@ -631,13 +631,13 @@ module Hanami
631
631
  # @since 2.0.0
632
632
  # @api private
633
633
  def not_allowed(env)
634
- (_not_allowed_fixed(env) || _not_allowed_variable(env)) and return NOT_ALLOWED
634
+ (_not_allowed_fixed(env) || _not_allowed_variable(env)) and return [405, { "Content-Length" => "11" }, ["Not Allowed"]]
635
635
  end
636
636
 
637
637
  # @since 2.0.0
638
638
  # @api private
639
639
  def not_found
640
- NOT_FOUND
640
+ [404, { "Content-Length" => "9" }, ["Not Found"]]
641
641
  end
642
642
 
643
643
  protected
@@ -666,7 +666,7 @@ module Hanami
666
666
  url = path(env, params)
667
667
  return env_for(url, params, options) # rubocop:disable Style/RedundantReturn
668
668
  rescue Hanami::Router::InvalidRouteException
669
- EMPTY_RACK_ENV.dup
669
+ {} # Empty Rack env
670
670
  end
671
671
  else
672
672
  env
@@ -691,31 +691,15 @@ module Hanami
691
691
  # @api private
692
692
  DEFAULT_REDIRECT_CODE = 301
693
693
 
694
- # @since 2.0.0
695
- # @api private
696
- NOT_FOUND = [404, { "Content-Length" => "9" }, ["Not Found"]].freeze
697
-
698
- # @since 2.0.0
699
- # @api private
700
- NOT_ALLOWED = [405, { "Content-Length" => "11" }, ["Not Allowed"]].freeze
701
-
702
694
  # @since 2.0.0
703
695
  # @api private
704
696
  PARAMS = "router.params"
705
697
 
706
- # @since 2.0.0
707
- # @api private
708
- EMPTY_PARAMS = {}.freeze
709
-
710
- # @since 2.0.0
711
- # @api private
712
- EMPTY_RACK_ENV = {}.freeze
713
-
714
698
  # @since 2.0.0
715
699
  # @api private
716
700
  def lookup(env)
717
701
  endpoint = fixed(env)
718
- return [endpoint, EMPTY_PARAMS] if endpoint
702
+ return [endpoint, {}] if endpoint
719
703
 
720
704
  variable(env) || globbed(env) || mounted(env)
721
705
  end
@@ -57,6 +57,8 @@ module Hanami
57
57
  # @since 2.0.0
58
58
  # @api private
59
59
  def _join(path)
60
+ return @prefix if path == DEFAULT_SEPARATOR
61
+
60
62
  (@prefix + DEFAULT_SEPARATOR + path)
61
63
  .gsub(DOUBLE_DEFAULT_SEPARATOR_REGEXP, DEFAULT_SEPARATOR)
62
64
  end
@@ -4,6 +4,6 @@ module Hanami
4
4
  class Router
5
5
  # @since 0.1.0
6
6
  # @api public
7
- VERSION = "2.0.0.alpha2"
7
+ VERSION = "2.0.0.alpha3"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha2
4
+ version: 2.0.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-19 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  - !ruby/object:Gem::Version
162
162
  version: 1.3.1
163
163
  requirements: []
164
- rubygems_version: 3.1.2
164
+ rubygems_version: 3.1.3
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Rack compatible HTTP router for Ruby and Hanami