fix for trailing slash problem

proposed fix for trailing slash problem that retains check to avoid
baddomain attacks (ie: server.com.baddomain.com)