Skip to content

Commit

Permalink
allow port numbers in the domain
Browse files Browse the repository at this point in the history
  • Loading branch information
steved committed Apr 18, 2012
1 parent 04ea374 commit 196356a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/weary/resource.rb
Expand Up @@ -22,7 +22,7 @@ def initialize(method, uri)
#
# Returns an Addressable::Template
def url(uri=nil)
@uri = Addressable::Template.new(uri.gsub(/:(\w+)/) { "{#{$1}}" }) unless uri.nil?
@uri = Addressable::Template.new(uri.gsub(/:(?![0-9])(\w+)/) { "{#{$1}}" }) unless uri.nil?
@uri
end

Expand Down Expand Up @@ -156,4 +156,4 @@ def pull_credentials(params)


end
end
end
8 changes: 7 additions & 1 deletion spec/weary/resource_spec.rb
Expand Up @@ -32,6 +32,12 @@
resource = Weary::Resource.new "GET", url
resource.url.variables.should include 'user'
end

it "accepts port numbers in the url" do
url = "http://localhost:3000/api/v2/"
resource = Weary::Resource.new "GET", url
resource.url.variables.should_not include '3000'
end
end

describe "#optional" do
Expand Down Expand Up @@ -253,4 +259,4 @@
req.params.should eql "user_id=markwunsch"
end
end
end
end

0 comments on commit 196356a

Please sign in to comment.