phusion/juvia — pull request #18 by JangoSteve (2013-01-15 17:20:06+00:00)
Title: Make topic key trailing-slash-insensitive.

I was having an issue where comments wouldn't show up for an article with a topic key of "/blog/some-article" if the current URL was passed to Juvia with a trailing slash ("/blog/some-article/"), which is exactly equivalent. So, I made the topic lookup fallback to a second lookup with or without a trailing slash.

In other words, if the initial lookup is without a trailing slash, and no comments are found, it'll do a second lookup with a trailing slash. And vice versa; if the initial lookup is with a trailing slash, then the second lookup will be without.

I could have implemented this as a single query with an `OR` statement:

```ruby
where(sites_table[:key].eq(site_key).and(topics_table[:key].eq(topic_key).or(topics_table[:key].eq(alt_key(topic_key)))))
```

But I wanted it to try an exact match first, and only fallback to the alternative match if there were no results, so that the exact match gets preference. Since this is a small query that only happens asynchronously once per page, the tradeoff of having two queries instead of one is small.