Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
try {
let urlParts = url.split('/'),
protocol = urlParts[0].replace(':', ''),
port = protocol === 'https' ? 443 : 80,
host = urlParts[2],
path = urlParts.filter((part, i) => {
return i > 2 ? part : false;
}).join('/');
mdnsAd = new mdns.Advertisement(mdns.tcp(protocol), port, {
'name': url,
'txtRecord': {
'path': path
},
'host': host,
'domain': 'local',
'ip': host
});
mdnsAd.start();
activeModes += '<span class="modes">mDNS</span>';
mainWindow.webContents.send('status', [`${url} ${activeModes}`, 'Broadcasting', true]);
console.log(`mdns broadcasting: ${url}`);
if (ws) {
ws.send(`mdns broadcasting: ${url}`);
}
resolve();