improved hostname support for js api