Class: Gitlab::UrlBlockers::DomainAllowlistEntry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, port: nil) ⇒ DomainAllowlistEntry

Returns a new instance of DomainAllowlistEntry.



8
9
10
11
# File 'lib/gitlab/url_blockers/domain_allowlist_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_allowlist_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_allowlist_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_allowlist_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