Added check for trailing slash.