Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sporkmonger/addressable
Browse files Browse the repository at this point in the history
  • Loading branch information
sporkmonger committed Oct 16, 2012
2 parents 421a88f + ee198d4 commit e3c73d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/addressable/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ def match(uri, processor=nil)
# First, we need to process the pattern, and extract the values.
expansions, expansion_regexp =
parse_template_pattern(pattern, processor)

return nil unless uri.to_str.match(expansion_regexp)
unparsed_values = uri.to_str.scan(expansion_regexp).flatten

if uri.to_str == pattern
Expand Down
9 changes: 9 additions & 0 deletions spec/addressable/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,15 @@ def self.transform(name, value)
data.mapping["foo"].should == "foo"
data.mapping["bar"].should == "banana"
end
it "can fail" do
subject.match("bar/foo").should be_nil
subject.match("foobaz").should be_nil
end
it "can match empty" do
data = subject.match("foo/baz")
data.mapping["foo"].should == ""
data.mapping["bar"].should == ""
end
it "lists vars" do
subject.variables.should == ["foo", "bar"]
end
Expand Down

0 comments on commit e3c73d1

Please sign in to comment.