diff options
author | James Lopez <james@jameslopez.es> | 2016-06-30 13:17:37 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-30 13:17:37 +0200 |
commit | 5b893d603dd68f263129523f13e8eb68b67fe790 (patch) | |
tree | f17be7ff52f89672f6895c45d0c15e687e50527a /lib/gitlab/url_sanitizer.rb | |
parent | 0ca275748314a27a1f36e12fe1360df11c9be25d (diff) | |
download | gitlab-ce-5b893d603dd68f263129523f13e8eb68b67fe790.tar.gz |
few changes based on feedback
Diffstat (limited to 'lib/gitlab/url_sanitizer.rb')
-rw-r--r-- | lib/gitlab/url_sanitizer.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/url_sanitizer.rb b/lib/gitlab/url_sanitizer.rb index 7d02fe3c971..2eb6085a3ca 100644 --- a/lib/gitlab/url_sanitizer.rb +++ b/lib/gitlab/url_sanitizer.rb @@ -1,5 +1,9 @@ module Gitlab class UrlSanitizer + + attr_reader :valid + alias_method :valid?, :valid + def self.sanitize(content) regexp = URI::Parser.new.make_regexp(['http', 'https', 'ssh', 'git']) @@ -7,8 +11,12 @@ module Gitlab end def initialize(url, credentials: nil) - @url = Addressable::URI.parse(url) + @valid = true + @url = Addressable::URI.parse(url.strip) @credentials = credentials + rescue Addressable::URI::InvalidURIError + @valid = false + raise end def sanitized_url |