diff --git a/CHANGELOG.md b/CHANGELOG.md index dfedf7e..74fc4a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 0.2.1 / _Not released yet_ +- Do not add the default port to complete URIs (e.g. `http://proxy`) ([GH-9][]) # 0.2.0 / 2013-07-05 @@ -23,3 +24,4 @@ [GH-5]: https://github.com/tmatilai/vagrant-proxyconf/issues/5 "Issue 5" [GH-7]: https://github.com/tmatilai/vagrant-proxyconf/issues/7 "Issue 7" [GH-8]: https://github.com/tmatilai/vagrant-proxyconf/issues/8 "Issue 8" +[GH-9]: https://github.com/tmatilai/vagrant-proxyconf/issues/9 "Issue 9" diff --git a/lib/vagrant-proxyconf/config/apt_proxy.rb b/lib/vagrant-proxyconf/config/apt_proxy.rb index 6618520..5681fde 100644 --- a/lib/vagrant-proxyconf/config/apt_proxy.rb +++ b/lib/vagrant-proxyconf/config/apt_proxy.rb @@ -84,7 +84,7 @@ def prefix end def suffix - ":#{default_port}" if value !~ %r{:\d+$} + ":#{default_port}" if value !~ %r{:\d+$} && value !~ %r{/} end def default_port diff --git a/spec/unit/support/shared/apt_proxy_config.rb b/spec/unit/support/shared/apt_proxy_config.rb index b5958a6..701f10b 100644 --- a/spec/unit/support/shared/apt_proxy_config.rb +++ b/spec/unit/support/shared/apt_proxy_config.rb @@ -9,7 +9,8 @@ def conf_line(proto, name, port = 3142) if name == :direct %Q{Acquire::#{proto}::Proxy "DIRECT";\n} else - %Q{Acquire::#{proto}::Proxy "#{proto}://#{name}:#{port}";\n} + port = ":#{port}" if port + %Q{Acquire::#{proto}::Proxy "#{proto}://#{name}#{port}";\n} end end @@ -41,7 +42,13 @@ def conf_line_pattern(proto, name, port = 3142) context "with protocol and name" do subject { config_with(proto => "#{proto}://proxy.foo.tld") } its(:enabled?) { should be_true } - its(:to_s) { should eq conf_line(proto, "proxy.foo.tld") } + its(:to_s) { should eq conf_line(proto, "proxy.foo.tld", nil) } + end + + context "with trailing slash" do + subject { config_with(proto => "#{proto}://proxy.foo.tld/") } + its(:enabled?) { should be_true } + its(:to_s) { should eq conf_line(proto, "proxy.foo.tld/", nil) } end context "with protocol and name and port" do