Check last URI character before removing hash

Fix for issue #2