Skip to content

Commit

Permalink
Merge pull request #9 from tmatilai/default-port
Browse files Browse the repository at this point in the history
Do not add the default port to complete URIs
  • Loading branch information
tmatilai committed Jul 8, 2013
2 parents cef596a + cbb1302 commit ecdbd3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"
2 changes: 1 addition & 1 deletion lib/vagrant-proxyconf/config/apt_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions spec/unit/support/shared/apt_proxy_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ecdbd3a

Please sign in to comment.