jj-middleware 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jj/middleware.rb +1 -1
- data/lib/jj/middleware/username_correction.rb +11 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88329120265b2a27fec81e527eb6cdf265155272
|
4
|
+
data.tar.gz: 3447e129bdc1fc4238a355bb138f62de78d4b6d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9166b5d94cf28d5a93f770c87952da7c852a1021bf72615b8a504f27debf0e9305da73f4f521e4b9ef8abdda0ab82a31c25d37a4d393ace46781a19427a5edfc
|
7
|
+
data.tar.gz: e85680d6052bbb939c8c6f5aed8af293bb4d6ca2d684c33e19bbf61967ebd5989faa3e9cc28c60840fb341dfeba483a9bb9db350bed4977fd507597c3ef83fa1
|
data/lib/jj/middleware.rb
CHANGED
@@ -9,11 +9,13 @@ module JJ
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
12
|
-
request
|
12
|
+
request = Rack::Request.new(env)
|
13
13
|
host_parts = request.host.split('.')
|
14
14
|
sub_domain = host_parts.shift
|
15
15
|
|
16
|
-
if
|
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?(
|
32
|
-
|
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
|
|