Normalize URI handling with trailing slashes

Implementation is consistent with the one proposed in #532
Merge pull request #727 from Sija/fix-trailing-slash

Fix matching routes with trailing slash (refs #532)