spec and fix for sanitize method

This commit is contained in:
James Lopez 2016-07-11 09:01:09 +02:00
parent 94e9d571c0
commit 99f7b6d246
2 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,8 @@ module Gitlab
regexp = URI::Parser.new.make_regexp(['http', 'https', 'ssh', 'git'])
content.gsub(regexp) { |url| new(url).masked_url }
rescue Addressable::URI::InvalidURIError
content.gsub(regexp, '')
end
def self.valid?(url)

View File

@ -45,6 +45,12 @@ describe Gitlab::UrlSanitizer, lib: true do
expect(filtered_content).to include("user@server:project.git")
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
describe '#sanitized_url' do