2016-03-21 08:15:51 -04:00
|
|
|
module Gitlab
|
2016-03-21 10:11:05 -04:00
|
|
|
class ImportUrl
|
|
|
|
def initialize(url, credentials: nil)
|
2016-03-21 08:15:51 -04:00
|
|
|
@url = URI.parse(url)
|
2016-03-21 10:11:05 -04:00
|
|
|
@credentials = credentials
|
2016-03-21 08:15:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def sanitized_url
|
|
|
|
@sanitized_url ||= safe_url.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def credentials
|
|
|
|
@credentials ||= { user: @url.user, password: @url.password }
|
|
|
|
end
|
|
|
|
|
2016-03-21 10:11:05 -04:00
|
|
|
def full_url
|
|
|
|
@full_url ||= generate_full_url.to_s
|
|
|
|
end
|
|
|
|
|
2016-03-21 08:15:51 -04:00
|
|
|
private
|
|
|
|
|
2016-03-21 10:11:05 -04:00
|
|
|
def generate_full_url
|
2016-03-21 13:09:47 -04:00
|
|
|
return @url unless credentials
|
2016-03-21 10:11:05 -04:00
|
|
|
@full_url = @url.dup
|
2016-03-21 13:09:47 -04:00
|
|
|
@full_url.user = credentials[:user]
|
|
|
|
@full_url.password = credentials[:password]
|
2016-03-21 10:11:05 -04:00
|
|
|
@full_url
|
|
|
|
end
|
|
|
|
|
2016-03-21 08:15:51 -04:00
|
|
|
def safe_url
|
|
|
|
safe_url = @url.dup
|
|
|
|
safe_url.password = nil
|
|
|
|
safe_url.user = nil
|
|
|
|
safe_url
|
|
|
|
end
|
|
|
|
end
|
2016-03-21 12:29:19 -04:00
|
|
|
end
|