fixes #6589 - add trusted_hosts check back

I've tried this, but the only difficulty then is tests, as the extensions aren't registered.  I could also register them in test_helper.rb - do you think that's better?