This seems like an unfortunate coupling of url trivia with view logic.  Is there really no better way to do this?