Permalink
Browse files

Merge branch 'master' of github.com:sporkmonger/addressable

  • Loading branch information...
sporkmonger committed Oct 16, 2012
2 parents 421a88f + ee198d4 commit e3c73d178c45b489907b8427d3a743e5be8c1df7
Showing with 11 additions and 0 deletions.
  1. +2 −0 lib/addressable/template.rb
  2. +9 −0 spec/addressable/template_spec.rb
@@ -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
@@ -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

0 comments on commit e3c73d1

Please sign in to comment.