Skip to content

Commit

Permalink
Merge pull request dtao#71 from sanemat/feature/spec-identity-url
Browse files Browse the repository at this point in the history
Fix trailing slash
  • Loading branch information
sanemat committed Dec 23, 2013
2 parents ae952c4 + c98c592 commit 74ad687
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tachikoma/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def target_repository_user(type, fetch_url, github_account)
end

def repository_identity(url)
%r!((?:[^/]*?)/(?:[^/]*?))(?:\.git)?$!.match(url)[1]
%r!((?:[^/]*?)/(?:[^/]*?))(?:\.git|/)?$!.match(url)[1]
end

def bundler_parallel_option(bundler_version, parallel_number)
Expand Down
18 changes: 18 additions & 0 deletions spec/tachikoma/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,22 @@
end
end
end

describe '#repository_identity' do
subject { described_class.new }
let(:identity) { 'example1/example2' }

context 'https with .git' do
let(:url) { 'https://github.com/example1/example2.git' }
it { expect(subject.repository_identity(url)).to eq identity }
end
context 'https without .git' do
let(:url) { 'https://github.com/example1/example2' }
it { expect(subject.repository_identity(url)).to eq identity }
end
context 'https with trail slash' do
let(:url) { 'https://github.com/example1/example2/' }
it { expect(subject.repository_identity(url)).to eq identity }
end
end
end

0 comments on commit 74ad687

Please sign in to comment.