From 6b99981b3b0b15d359ae3c305a75be46b00a0c81 Mon Sep 17 00:00:00 2001 From: cs8425 Date: Thu, 9 Feb 2017 14:32:34 +0800 Subject: [PATCH] remove doubled up on tcp port validity checks --- js/serial.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/js/serial.js b/js/serial.js index a4f57bf7..e56bc5d5 100644 --- a/js/serial.js +++ b/js/serial.js @@ -18,18 +18,11 @@ var serial = { logHead: 'SERIAL: ', connect: function (path, options, callback) { - var self = this; - var testUrl = path.match(/^tcp:\/\/([A-Za-z0-9\.-]+)(?:\:(\d+))?$/) if (testUrl) { - var ip = testUrl[1]; - var port = testUrl[2] || 2323; - port = parseInt(port); - - console.log('connect to raw tcp:', ip + ':' + port) - self.connectTcp(ip, port, options, callback); + this.connectTcp(testUrl[1], testUrl[2], options, callback); } else { - self.connectSerial(path, options, callback); + this.connectSerial(path, options, callback); } }, connectSerial: function (path, options, callback) { @@ -174,6 +167,7 @@ var serial = { self.connectionType = 'tcp'; self.logHead = 'SERIAL-TCP: '; + console.log('connect to raw tcp:', ip + ':' + port) chrome.sockets.tcp.create({}, function(createInfo) { console.log('chrome.sockets.tcp.create', createInfo) if (createInfo && !self.openCanceled) {