Strip protocol information from host field, checking for encryption

Fixes #1192
master
Lorenz Hübschle-Schneider 4 years ago
parent 6e45939f38
commit bc41cab976
  1. 13
      src/js/glowingbear.js

@ -663,9 +663,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.hostInvalid = false;
var parts;
var regexProto = /^(https?|wss?):\/\/(.+)$/;
var regexHost = /^([^:\/]*|\[.*\])$/;
var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/;
var regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/;
var regexHostPortPath = /^([^:]*|\[.*\]):(\d+)\/(.+)$/;
// First, remove possible protocol info - we don't want it
if ((parts = regexProto.exec(settings.hostField)) !== null) {
settings.hostField = parts[2];
if (parts[1] === "http" || parts[1] === "ws") {
settings.ssl = false;
} else if (parts[1] === "https" || parts[1] === "wss") {
settings.ssl = true;
}
}
if ((parts = regexHost.exec(settings.hostField)) !== null) { //host only
settings.host = parts[1];

Loading…
Cancel
Save