localhost causing nil exception.

When using http://localhost/, nil exception will be thrown.
This is because its unusual TLD length cause exception when finding domain.
Use Rails build-in method for finding domain. It will be more accurate since it uses the `tld_length` setting in Rails.