jj-middleware 3.1.1 → 3.1.2

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
  SHA1:
3
- metadata.gz: c8697c185d2706398041c54c46d161a3e2999046
4
- data.tar.gz: f6d7107453964aaeb88c04fcb28e1e278c77478e
3
+ metadata.gz: 88329120265b2a27fec81e527eb6cdf265155272
4
+ data.tar.gz: 3447e129bdc1fc4238a355bb138f62de78d4b6d5
5
5
  SHA512:
6
- metadata.gz: 32546eb6b323c6763e4fa35df331348f588b60e4a3a7c1eab648c26c5d91dc44ea3d6d63f0ae1bb48ba4667036aaf3e736678f01e2df139e53efc71bca560887
7
- data.tar.gz: e045e771531b66e4ea970f8bf1d2afd4bb1a4af079bed7ade61c8781dc967c9016dfd4b310f8f4c505b158495ba22cadd3ba95c9fe823f7ace4b6d52dbb6ec4d
6
+ metadata.gz: 9166b5d94cf28d5a93f770c87952da7c852a1021bf72615b8a504f27debf0e9305da73f4f521e4b9ef8abdda0ab82a31c25d37a4d393ace46781a19427a5edfc
7
+ data.tar.gz: e85680d6052bbb939c8c6f5aed8af293bb4d6ca2d684c33e19bbf61967ebd5989faa3e9cc28c60840fb341dfeba483a9bb9db350bed4977fd507597c3ef83fa1
@@ -1,5 +1,5 @@
1
1
  module JJ
2
2
  module Middleware
3
- VERSION = '3.1.1'.freeze
3
+ VERSION = '3.1.2'.freeze
4
4
  end
5
5
  end
@@ -9,11 +9,13 @@ module JJ
9
9
  end
10
10
 
11
11
  def call(env)
12
- request = Rack::Request.new(env)
12
+ request = Rack::Request.new(env)
13
13
  host_parts = request.host.split('.')
14
14
  sub_domain = host_parts.shift
15
15
 
16
- if on_profile_page?(sub_domain, request) || status_endpoint?(request)
16
+ if on_creator_subdomain?(sub_domain) ||
17
+ on_profile_page?(request) ||
18
+ status_endpoint?(request)
17
19
  @app.call(env)
18
20
  else
19
21
  redirect(generate_path(host_parts, request), 301)
@@ -24,19 +26,23 @@ module JJ
24
26
 
25
27
  CREATOR_SUB_DOMAIN = 'creator'
26
28
 
29
+ def on_creator_subdomain?(sub_domain)
30
+ sub_domain == CREATOR_SUB_DOMAIN
31
+ end
32
+
27
33
  def status_endpoint?(request)
28
34
  request.path == '/status'
29
35
  end
30
36
 
31
- def on_profile_page?(sub_domain, request)
32
- sub_domain != CREATOR_SUB_DOMAIN && request.path == '/'
37
+ def on_profile_page?(request)
38
+ request.path == '/'
33
39
  end
34
40
 
35
41
  def generate_path(parts, request)
36
42
  path_format = '%s://%s%s'
37
43
  path = parts.unshift(CREATOR_SUB_DOMAIN).join('.')
38
44
 
39
- if ![80,443].include?(request.port)
45
+ if ![80, 443].include?(request.port)
40
46
  path << format(':%s', request.port)
41
47
  end
42
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jj-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''