Class: Gitlab::UrlBlockers::DomainWhitelistEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/url_blockers/domain_whitelist_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, port: nil) ⇒ DomainWhitelistEntry

Returns a new instance of DomainWhitelistEntry.


8
9
10
11
# File 'lib/gitlab/url_blockers/domain_whitelist_entry.rb', line 8

def initialize(domain, port: nil)
  @domain = domain
  @port = port
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain


6
7
8
# File 'lib/gitlab/url_blockers/domain_whitelist_entry.rb', line 6

def domain
  @domain
end

#portObject (readonly)

Returns the value of attribute port


6
7
8
# File 'lib/gitlab/url_blockers/domain_whitelist_entry.rb', line 6

def port
  @port
end

Instance Method Details

#match?(requested_domain, requested_port = nil) ⇒ Boolean

Returns:

  • (Boolean)

13
14
15
16
17
18
# File 'lib/gitlab/url_blockers/domain_whitelist_entry.rb', line 13

def match?(requested_domain, requested_port = nil)
  return false unless domain == requested_domain
  return true if port.nil?

  port == requested_port
end