From ec057315c0aaa686bcf145408487c1d6ae8256d8 Mon Sep 17 00:00:00 2001 From: Brendan ODonnell Date: Wed, 18 Mar 2015 14:41:22 -0500 Subject: [PATCH 1/2] Check ints for the end of string before seperator --- trie.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trie.go b/trie.go index fe4c517..22593b5 100644 --- a/trie.go +++ b/trie.go @@ -377,6 +377,11 @@ func (s *intMatcher) match(iter *charIter) bool { c, sep, ok := iter.next() count++ + // if it's the end of the string, it's a match + if !ok { + return true + } + // if the current character is not a number: // - it's either a separator that means it's a match // - it's some other character that means it's not a match @@ -391,11 +396,6 @@ func (s *intMatcher) match(iter *charIter) bool { return false } } - - // if it's the end of the string, it's a match - if !ok { - return true - } } } From 1db90dbad9677e27e8e49cda7ef1c64fa97050c9 Mon Sep 17 00:00:00 2001 From: Brendan ODonnell Date: Wed, 18 Mar 2015 15:27:24 -0500 Subject: [PATCH 2/2] Add a test case for int matches at the end of urls --- trie_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trie_test.go b/trie_test.go index fe7d490..0806494 100644 --- a/trie_test.go +++ b/trie_test.go @@ -233,6 +233,12 @@ func (s *TrieSuite) TestMergeAndMatchCases(c *C) { "http://google.com/v42/domains/domain1", "/v/domains/", }, + // Int matcher at the end of the Trie + { + []string{"/v/domains/"}, + "http://google.com/v42/domains/1", + "/v/domains/", + }, // Int matcher, no match { []string{"/v/domains/", "//domains/"},