Skip to content
Snippets Groups Projects
Commit 99f7b6d2 authored by James Lopez's avatar James Lopez
Browse files

spec and fix for sanitize method

parent 94e9d571
No related branches found
No related tags found
No related merge requests found
Loading
@@ -4,6 +4,8 @@ module Gitlab
Loading
@@ -4,6 +4,8 @@ module Gitlab
regexp = URI::Parser.new.make_regexp(['http', 'https', 'ssh', 'git']) regexp = URI::Parser.new.make_regexp(['http', 'https', 'ssh', 'git'])
   
content.gsub(regexp) { |url| new(url).masked_url } content.gsub(regexp) { |url| new(url).masked_url }
rescue Addressable::URI::InvalidURIError
content.gsub(regexp, '')
end end
   
def self.valid?(url) def self.valid?(url)
Loading
Loading
Loading
@@ -45,6 +45,12 @@ describe Gitlab::UrlSanitizer, lib: true do
Loading
@@ -45,6 +45,12 @@ describe Gitlab::UrlSanitizer, lib: true do
   
expect(filtered_content).to include("user@server:project.git") expect(filtered_content).to include("user@server:project.git")
end end
it 'returns an empty string for invalid URLs' do
filtered_content = sanitize_url('ssh://')
expect(filtered_content).to include("repository '' not found")
end
end end
   
describe '#sanitized_url' do describe '#sanitized_url' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment