Commit a5a94d13 authored by Peter Leitzen's avatar Peter Leitzen

Fix extracting Sentry external URL when URL is nil

parent 01ec170d
......@@ -128,7 +128,7 @@ module ErrorTracking
# ->
# http://HOST/ORG/PROJECT
def self.extract_sentry_external_url(url)
url.sub('api/0/projects/', '')
url&.sub('api/0/projects/', '')
end
def api_host
......
---
title: Fix extracting Sentry external URL when URL is nil
merge_request: 23162
author:
type: fixed
......@@ -64,6 +64,22 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
describe '.extract_sentry_external_url' do
subject { described_class.extract_sentry_external_url(sentry_url) }
describe 'when passing a URL' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
it { is_expected.to eq('https://sentrytest.gitlab.com/sentry-org/sentry-project') }
end
describe 'when passing nil' do
let(:sentry_url) { nil }
it { is_expected.to be_nil }
end
end
describe '#sentry_external_url' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment