Make topic key trailing-slash-insensitive. #18

Merged
merged 1 commit into from Jan 30, 2013

Conversation

Projects
None yet
2 participants
Collaborator

JangoSteve commented Jan 15, 2013

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:

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.

Owner

FooBarWidget commented Jan 30, 2013

Alright, this looks good.
Sorry for the delay in reviewing, for some reason Github didn't send me any pull request emails.

FooBarWidget added a commit that referenced this pull request Jan 30, 2013

Merge pull request #18 from alfajango/topic-key-trailing-slash
Make topic key trailing-slash-insensitive.

@FooBarWidget FooBarWidget merged commit 7c6921d into phusion:master Jan 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment