Commit b2e7ff6d authored by Kurry Tran's avatar Kurry Tran

fixes crash when using file URLs https://github.com/CocoaPods/CocoaPods/issues/2683

parent 8576267d
......@@ -28,6 +28,9 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[#2627](https://github.com/CocoaPods/CocoaPods/issues/2627)
[#2665](https://github.com/CocoaPods/CocoaPods/issues/2665)
* Fixes a crash when using file URLs as a source.
[Kurry Tran](https://github.com/kurry)
[#2683](https://github.com/CocoaPods/CocoaPods/issues/2683)
## 0.34.2
......
......@@ -410,6 +410,11 @@ module Pod
# name_for_url('https://sourceforge.org/Artsy/Specs.git')
# # sourceforge-artsy-specs
#
# @example A file URL
#
# name_for_url('file:///Artsy/Specs.git')
# # artsy-specs
#
# @param [#to_s] url
# The URL of the source.
#
......@@ -417,8 +422,13 @@ module Pod
#
def name_for_url(url)
base_from_host_and_path = lambda do |host, path|
base = host.split('.')[-2] || host
base += '-' + path.gsub(/.git$/, '').gsub(/^\//, '').
if host.nil?
base = ''
else
base = host.split('.')[-2] || host
base += '-'
end
base += path.gsub(/.git$/, '').gsub(/^\//, '').
split('/').join('-')
end
......
......@@ -138,6 +138,18 @@ module Pod
SourcesManager.send(:name_for_url, url).
should == 'companyalias-pod-specs'
end
it 'supports file URLs' do
url = 'file:///Users/kurrytran/pod-specs'
SourcesManager.send(:name_for_url, url).
should == 'users-kurrytran-pod-specs'
end
it 'uses the repo name if no parent directory' do
url = 'file:///pod-specs'
SourcesManager.send(:name_for_url, url).
should == 'pod-specs'
end
it 'supports ssh URLs with no user component' do
url = 'ssh://company.com/pods/specs.git'
......
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