Added safe encodeURIcomponent to eliminate errors on malformed captures.
Merge pull request #1735 from lxe/malformed-capture-route

Wrapped encodeURIcomponent in try-catch to eliminate errors on malformed captures.