reredos 0.1.1 → 0.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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +3 -0
- data/lib/reredos/version.rb +1 -1
- data/lib/reredos.rb +29 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3547add122783213f2b2d21781effdcdbccf443b46faefcbbc8040896b3604e9
|
4
|
+
data.tar.gz: 92f229dfe56e23bd74a0b722f8cd200f5e8631abf37821d749cc56a55f7c97e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 899fe67f6ea0adfcc74e257313f09f383accff312b8c701fded469fa8bd81f28d0a95ac1bc42626580666f7234a1edfc2e58c213237e47a8dcf93071152e2d91
|
7
|
+
data.tar.gz: fc9c2e4c6a6ea49b129cb85c52c3f595b197554c0b4b1282441333997d9fb8a76978e2f6d6112c7457bf231b1929bbf3c37ac2912665b9b0cac4930f7e6a344b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -48,6 +48,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
48
48
|
Everyone interacting in the Reredos project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/reredos/blob/master/CODE_OF_CONDUCT.md).
|
49
49
|
|
50
50
|
## Release Notes
|
51
|
+
### 0.1.2 - July 29, 2019
|
52
|
+
* Fixed a bug, that it accepted dots as first or last character of username
|
53
|
+
|
51
54
|
### 0.1.1 - April 26, 2019
|
52
55
|
* Fixed a bug, that it accepted strings including new line
|
53
56
|
|
data/lib/reredos/version.rb
CHANGED
data/lib/reredos.rb
CHANGED
@@ -20,18 +20,42 @@ module Reredos
|
|
20
20
|
|
21
21
|
def valid_domain?(str)
|
22
22
|
return false if str.length > DOMAIN_MAX_LENGTH
|
23
|
-
return false
|
24
|
-
|
25
|
-
labels = str.split('.')
|
26
|
-
return false if labels.map(&:length).any?{ |_| _ > DOMAIN_LABEL_MAX_LENGTH }
|
27
|
-
return false unless labels.map{ |_| /\A[0-9a-zA-Z\-]+\z/ === _ }.all? # ラベルに含まれる文字が1文字以上の英数字orハイフン
|
23
|
+
return false unless str.split('.').all? { |l| valid_label?(l) }
|
28
24
|
|
29
25
|
true
|
30
26
|
end
|
31
27
|
|
32
28
|
def valid_username?(str)
|
33
29
|
return false if str.length > USERNAME_MAX_LENGTH
|
30
|
+
return false if str[0] == '.' || str[-1] == '.'
|
34
31
|
/\A[0-9a-zA-Z\.\+\-\_]+\z/ === str # 既定の文字のみで構成されている
|
35
32
|
end
|
33
|
+
|
34
|
+
# ラベルはアルファベットで始まり、アルファベットか数字かハイフンが続き、アルファベットか数字で終わる
|
35
|
+
def valid_label?(str)
|
36
|
+
return false if str.empty?
|
37
|
+
return false if str.length > DOMAIN_LABEL_MAX_LENGTH
|
38
|
+
return false unless letter?(str[0])
|
39
|
+
return false unless alphanumeric?(str[-1])
|
40
|
+
return true if str[1...-1].empty?
|
41
|
+
|
42
|
+
str[1...-1].chars.all? { |c| hyphen_or_alphanumeric?(c) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def letter?(char)
|
46
|
+
('a'..'z').include?(char) || ('A'..'Z').include?(char)
|
47
|
+
end
|
48
|
+
|
49
|
+
def digit?(char)
|
50
|
+
('0'..'9').include?(char)
|
51
|
+
end
|
52
|
+
|
53
|
+
def alphanumeric?(char)
|
54
|
+
letter?(char) || digit?(char)
|
55
|
+
end
|
56
|
+
|
57
|
+
def hyphen_or_alphanumeric?(char)
|
58
|
+
char == '-' || alphanumeric?(char)
|
59
|
+
end
|
36
60
|
end
|
37
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reredos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- expajp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|