Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix for #80. #82

Merged
merged 1 commit into from Aug 2, 2012
Jump to file or symbol
Failed to load files and symbols.
+11 −0
Split
@@ -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