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 ...@@ -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) [#2627](https://github.com/CocoaPods/CocoaPods/issues/2627)
[#2665](https://github.com/CocoaPods/CocoaPods/issues/2665) [#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 ## 0.34.2
......
...@@ -410,6 +410,11 @@ module Pod ...@@ -410,6 +410,11 @@ module Pod
# name_for_url('https://sourceforge.org/Artsy/Specs.git') # name_for_url('https://sourceforge.org/Artsy/Specs.git')
# # sourceforge-artsy-specs # # sourceforge-artsy-specs
# #
# @example A file URL
#
# name_for_url('file:///Artsy/Specs.git')
# # artsy-specs
#
# @param [#to_s] url # @param [#to_s] url
# The URL of the source. # The URL of the source.
# #
...@@ -417,8 +422,13 @@ module Pod ...@@ -417,8 +422,13 @@ module Pod
# #
def name_for_url(url) def name_for_url(url)
base_from_host_and_path = lambda do |host, path| base_from_host_and_path = lambda do |host, path|
if host.nil?
base = ''
else
base = host.split('.')[-2] || host base = host.split('.')[-2] || host
base += '-' + path.gsub(/.git$/, '').gsub(/^\//, ''). base += '-'
end
base += path.gsub(/.git$/, '').gsub(/^\//, '').
split('/').join('-') split('/').join('-')
end end
......
...@@ -139,6 +139,18 @@ module Pod ...@@ -139,6 +139,18 @@ module Pod
should == 'companyalias-pod-specs' should == 'companyalias-pod-specs'
end 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 it 'supports ssh URLs with no user component' do
url = 'ssh://company.com/pods/specs.git' url = 'ssh://company.com/pods/specs.git'
SourcesManager.send(:name_for_url, url). SourcesManager.send(:name_for_url, url).
......
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