Fix trailing slash issue. Fixes #1691