Merge pull request #1193 from glowing-bear/strip-protocol

Strip protocol information from host field, checking for encryption
master
Lorenz Hübschle-Schneider 4 years ago committed by GitHub
commit 5d554152bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/js/glowingbear.js

@ -663,9 +663,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.hostInvalid = false; $rootScope.hostInvalid = false;
var parts; var parts;
var regexProto = /^(https?|wss?):\/\/(.+)$/;
var regexHost = /^([^:\/]*|\[.*\])$/; var regexHost = /^([^:\/]*|\[.*\])$/;
var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; 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 if ((parts = regexHost.exec(settings.hostField)) !== null) { //host only
settings.host = parts[1]; settings.host = parts[1];

Loading…
Cancel
Save