Sanitize paths ending in / or ?. Fixes GH-353