Fix issue where security can be bypassed if a trailing slash is present.