Use String::startsWith
Remove unneeded trailing slash check

Package names don’t have these anyway and file paths
won’t be ending with them.
Return early when no candidates exist