Method: Sentry::DSN#initialize

Defined in:
lib/sentry/dsn.rb

#initialize(dsn_string) ⇒ DSN

Returns a new instance of DSN.


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sentry/dsn.rb', line 12

def initialize(dsn_string)
  @raw_value = dsn_string

  uri = URI.parse(dsn_string)
  uri_path = uri.path.split("/")

  if uri.user
    # DSN-style string
    @project_id = uri_path.pop
    @public_key = uri.user
    @secret_key = !(uri.password.nil? || uri.password.empty?) ? uri.password : nil
  end

  @scheme = uri.scheme
  @host = uri.host
  @port = uri.port if uri.port
  @path = uri_path.join("/")
end