gman 8.1.0 → 8.2.0

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: 29b30e2a1e50e8e0f8f7d5ca50a6c2a8671b1e69a1d8213415bd6d6a70a35af9
4
- data.tar.gz: 07b8f53008e8699d2f67ef162460540196cd90c3e89e1ed3a4054a185b0a325f
3
+ metadata.gz: 79ceaf4838ca91d410793c34d49b5fbc5e3ce83a28e50620a5e21df95d47544b
4
+ data.tar.gz: e9bbc0393a6b26b98adfba86970d4e55a51404cad10fcdd15d267e5f2ae30974
5
5
  SHA512:
6
- metadata.gz: 25c6626204645cfbc03b7875ddb5a7eb51d18d56b5f70af1f993def0ece5841a36b27e151c2e517eee4060059627f648f1883c45216d50b68ee1f749ea4999de
7
- data.tar.gz: 5ca3b6cba72c5bf9238abaa014c61f9caaeaa10bcc4a0f147b27f92fb5fa96a2fff835fbd2b479764429d6ce6e0e1bd15937b8f371c8483dbb63724ebbafb032
6
+ metadata.gz: 255989a15642e7626fa7e7e55086686b69ae3ee3e42188f894ecbaf48ed9a2a24d4457945aa64a5fe4783d693ff39c907e6de25bc052198a89d430a9869141a5
7
+ data.tar.gz: 79af4a684fd94d5aa626271d67fba5b79ce59f522ab287f28e32050a3a9d0919c4c6131e3ab0a6f34cc12093a96deb0afa28296084639138881a87183b8ad1d8
data/lib/gman/locality.rb CHANGED
@@ -27,12 +27,15 @@ class Gman
27
27
  parish town twp vi vil village
28
28
  ].freeze
29
29
 
30
+ # Anchored so the locality must be the end of the hostname and start at a
31
+ # label boundary (e.g. not state.il.us.example.com or state.ca.usexample.com)
30
32
  REGEX = /
33
+ (?:\A|\.)
31
34
  (
32
35
  (#{Regexp.union(AFFINITY_NAMESPACES)})
33
36
  |
34
37
  (#{Regexp.union(LOCALITY_DOMAINS)})\.[a-z-]+
35
- )\.(#{Regexp.union(STATES)})\.us
38
+ )\.(#{Regexp.union(STATES)})\.us\z
36
39
  /x
37
40
 
38
41
  def self.valid?(domain)
data/lib/gman/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Gman
4
- VERSION = '8.1.0'
4
+ VERSION = '8.2.0'
5
5
  end
data/lib/gman.rb CHANGED
@@ -54,6 +54,24 @@ class Gman
54
54
 
55
55
  private
56
56
 
57
+ # Overrides NaughtyOrNice#normalized_domain, which parses every input as a
58
+ # URL. For an email address, the URL host can differ from the domain mail is
59
+ # delivered to (e.g. "x@gsa.gov#"@example.com), so the domain after the last
60
+ # @ must be the same host the URL parser sees.
61
+ #
62
+ # Returns the domain string, or nil
63
+ def normalized_domain
64
+ return if @text.match?(/[[:space:][:cntrl:]]/)
65
+ return super unless email_like?
66
+
67
+ host = @text.rpartition('@').last
68
+ host if host == super
69
+ end
70
+
71
+ def email_like?
72
+ @text.include?('@') && !%r{\Ahttps?://}.match?(@text)
73
+ end
74
+
57
75
  def valid_domain?
58
76
  !domain.nil? && !academic?
59
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gman
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 8.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter