Factor port_matches() out of url_match().