@@ -38,18 +38,18 @@ const PROTOCOL = {
3838 HTTPS : 'https'
3939} ;
4040
41- const LOOPBACK_ADDRESS = ' 127.0.0.1' ;
42- const LOOPBACK_HOSTNAME = ' localhost' ;
41+ const LOOPBACK_ADDRESS = ` ${ PROTOCOL . HTTP } :// 127.0.0.1` ;
42+ const LOOPBACK_HOST = ` ${ PROTOCOL . HTTPS } :// localhost` ;
4343const LOOKUP_PORT_START = 8991 ;
4444const LOOKUP_PORT_END = 9000 ;
45- let orderedPluginAddresses = [ LOOPBACK_ADDRESS , LOOPBACK_HOSTNAME ] ;
45+ let orderedPluginAddresses = [ LOOPBACK_ADDRESS , LOOPBACK_HOST ] ;
4646
4747const CANT_FIND_AGENT_MESSAGE = 'Arduino Create Agent cannot be found' ;
4848
4949let updateAttempts = 0 ;
5050
5151if ( browser . name !== 'chrome' && browser . name !== 'firefox' ) {
52- orderedPluginAddresses = [ LOOPBACK_HOSTNAME , LOOPBACK_ADDRESS ] ;
52+ orderedPluginAddresses = [ LOOPBACK_HOST , LOOPBACK_ADDRESS ] ;
5353}
5454
5555export default class SocketDaemon extends Daemon {
@@ -89,7 +89,7 @@ export default class SocketDaemon extends Daemon {
8989
9090 /**
9191 * Look for the agent endpoint.
92- * First search in http:// LOOPBACK_ADDRESS, after in https://LOOPBACK_HOSTNAME if in Chrome or Firefox, otherwise vice versa.
92+ * First search in LOOPBACK_ADDRESS, after in LOOPBACK_HOST if in Chrome or Firefox, otherwise vice versa.
9393 */
9494 findAgent ( ) {
9595 this . _tryPorts ( orderedPluginAddresses [ 0 ] )
@@ -99,15 +99,15 @@ export default class SocketDaemon extends Daemon {
9999 }
100100
101101 /**
102- * Try ports for the selected hostname . From LOOKUP_PORT_START to LOOKUP_PORT_END
103- * @param {string } hostname - The hostname value (LOOPBACK_ADDRESS or LOOPBACK_HOSTNAME ).
102+ * Try ports for the selected host . From LOOKUP_PORT_START to LOOKUP_PORT_END
103+ * @param {string } host - The host value (LOOPBACK_ADDRESS or LOOPBACK_HOST ).
104104 * @return {Promise } info - A promise resolving with the agent info values.
105105 */
106- _tryPorts ( hostname ) {
106+ _tryPorts ( host ) {
107107 const pluginLookups = [ ] ;
108108
109109 for ( let port = LOOKUP_PORT_START ; port < LOOKUP_PORT_END ; port += 1 ) {
110- pluginLookups . push ( fetch ( `${ this . selectedProtocol } :// ${ hostname } :${ port } /info` )
110+ pluginLookups . push ( fetch ( `${ host } :${ port } /info` )
111111 . then ( response => response . json ( ) . then ( data => ( { response, data } ) ) )
112112 . catch ( ( ) => Promise . resolve ( false ) ) ) ;
113113 // We expect most of those call to fail, because there's only one agent
@@ -157,7 +157,7 @@ export default class SocketDaemon extends Daemon {
157157 if ( this . channelOpen . getValue ( ) === null ) {
158158 this . channelOpen . next ( false ) ;
159159 }
160- return Promise . reject ( new Error ( `${ CANT_FIND_AGENT_MESSAGE } at ${ hostname } ` ) ) ;
160+ return Promise . reject ( new Error ( `${ CANT_FIND_AGENT_MESSAGE } at ${ host } ` ) ) ;
161161 } ) ;
162162 }
163163
0 commit comments