function lookupURL = getLookupURLOrHost( jmprx )
% We need to store the lookupURL in case the mjs service has been started with a
% non-default baseport. However if the default was used, we don't want to
% unnecessarily display the baseport in the profile.
%
% Note that the input, jmprx, can sometimes be a JobmanagerServiceInfo.
% This is to help with reducing the number of remote calls required when
% querying properties of the Jobmanager. 

%   Copyright 2014-2018 The MathWorks, Inc.

lookupURL = char( jmprx.getLookupURL );
% Include the separator so we don't match a host that happens to have the default
% base port in its name.
defaultBasePort = [ ':' num2str( com.mathworks.toolbox.distcomp.control.PortConfig.DEFAULT_BASE_PORT ) ];
len = length( defaultBasePort );
if isempty( lookupURL ) || length( lookupURL ) > len && strcmp( lookupURL(end-(len-1):end), defaultBasePort )
    lookupURL = char( jmprx.getHostName );
end
end
