BigW Consortium Gitlab

Commit f2f345e6 by James Lopez

avoid encoding import url and delegate good format to user

parent 8a91f3f2
module Gitlab
class ImportUrl
def initialize(url, credentials: nil)
@url = URI.parse(encode(url))
@url = URI.parse(url)
@credentials = credentials
end
......@@ -37,9 +37,5 @@ module Gitlab
def valid_credentials?
credentials && credentials.is_a?(Hash) && credentials.any?
end
def encode(url)
URI.decode(url).size < url.size ? url : URI.encode(url)
end
end
end
......@@ -19,16 +19,4 @@ describe Gitlab::ImportUrl do
describe 'credentials' do
it { expect(import_url.credentials).to eq(credentials) }
end
context 'URL encoding' do
describe 'not encoded URL' do
let(:url) { "https://github.com/me/my project.git" }
it { expect(import_url.sanitized_url).to eq("https://github.com/me/my%20project.git") }
end
describe 'already encoded URL' do
let(:url) { "https://github.com/me/my%20project.git" }
it { expect(import_url.sanitized_url).to eq("https://github.com/me/my%20project.git") }
end
end
end
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