utilities/service-utils.js
function(serviceName, returnBoolean, alchemyRegex) {
    var regex = alchemyRegex ?
                RegExp('(http|https)(://)('+serviceName+').*') :
                RegExp('(http|https)(://)([^\/]+)(/)('+serviceName+').*');

    var services = appEnv.getServices();

    for (var service in services) {
      if (services[service].hasOwnProperty('credentials')) {
        if (services[service].credentials.hasOwnProperty('url')){
          if (services[service].credentials.url.search(regex) === 0){
            return returnBoolean ? true : services[service].credentials;
          }
        }
      }
    }
    return returnBoolean ? false : null;
  }
function(serviceName, returnBoolean, alchemyRegex) {
    var regex = alchemyRegex ?
                RegExp('(http|https)(://)('+serviceName+').*') :
                RegExp('(http|https)(://)([^\/]+)(/)('+serviceName+').*');

    var services = appEnv.getServices();

    for (var service in services) {
      if (services[service].hasOwnProperty('credentials')) {
        if (services[service].credentials.hasOwnProperty('url')){
          if (services[service].credentials.url.search(regex) === 0){
            return returnBoolean ? true : services[service].credentials;
          }
        }
      }
    }
    return returnBoolean ? false : null;
  }
function ( serviceName , returnBoolean , alchemyRegex ) { var regex = alchemyRegex ? RegExp ( '(http|https)(://)(' + serviceName + ').*' ) : RegExp ( '(http|https)(://)([^\/]+)(/)(' + serviceName + ').*' ) ; var services = appEnv . getServices ( ) ; for ( var service in services ) { if ( services [ service ] . hasOwnProperty ( 'credentials' ) ) { if ( services [ service ] . credentials . hasOwnProperty ( 'url' ) ) { if ( services [ service ] . credentials . url . search ( regex ) === 0 ) { return returnBoolean ? true : services [ service ] . credentials ; } } } } return returnBoolean ? false : null ; }
function to determine if WDC service is bound. A simple check on name may fail because of duplicate usage. This function verifies that the url associated with the service, contains the matched input value, hence reducing the chances of a false match.
function to determine if WDC service is bound . A simple check on name may fail because of duplicate usage . This function verifies that the url associated with the service contains the matched input value hence reducing the chances of a false match .