@@ -61,7 +61,8 @@ var GAX_CONFIG = {
6161 * reliable, many-to-many, asynchronous messaging service from Cloud
6262 * Platform.
6363 *
64- * The `PUBSUB_EMULATOR_HOST` environment variable from the gcloud SDK is
64+ * The `host` from options will set the host. If not set, the
65+ * `PUBSUB_EMULATOR_HOST` environment variable from the gcloud SDK is
6566 * honored, otherwise the actual API endpoint will be used.
6667 *
6768 * @constructor
@@ -78,7 +79,7 @@ function PubSub(options) {
7879 }
7980
8081 this . defaultBaseUrl_ = 'pubsub.googleapis.com' ;
81- this . determineBaseUrl_ ( ) ;
82+ this . determineBaseUrl_ ( options . host ) ;
8283
8384 var config = {
8485 baseUrl : this . baseUrl_ ,
@@ -802,14 +803,14 @@ PubSub.prototype.request = function(protoOpts) {
802803 *
803804 * @private
804805 */
805- PubSub . prototype . determineBaseUrl_ = function ( ) {
806+ PubSub . prototype . determineBaseUrl_ = function ( host ) {
806807 var baseUrl = this . defaultBaseUrl_ ;
807808 var leadingProtocol = new RegExp ( '^https*://' ) ;
808809 var trailingSlashes = new RegExp ( '/*$' ) ;
809810
810- if ( process . env . PUBSUB_EMULATOR_HOST ) {
811+ if ( host || process . env . PUBSUB_EMULATOR_HOST ) {
811812 this . customEndpoint_ = true ;
812- baseUrl = process . env . PUBSUB_EMULATOR_HOST ;
813+ baseUrl = host || process . env . PUBSUB_EMULATOR_HOST ;
813814 }
814815
815816 this . baseUrl_ = baseUrl
0 commit comments