Merge pull request #169 from openHPI/edge-compat

Edge compat
This commit is contained in:
rteusner
2018-05-16 14:59:13 +02:00
committed by GitHub
5 changed files with 13 additions and 8 deletions

View File

@ -552,6 +552,10 @@ configureEditors: function () {
},
showWebsocketError: function() {
if (window.navigator.userAgent.indexOf('Edge') > -1) {
// Mute errors in Microsoft Edge
return;
}
$.flash.danger({
text: $('#flash').data('message-failure')
});

View File

@ -4,10 +4,11 @@ CodeOceanEditorWebsocket = {
createSocketUrl: function(url) {
var sockURL = new URL(window.location);
sockURL.pathname = url;
sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'] %>';
// sanitize socket protocol string, strip trailing slash and other malicious chars if they are there
sockURL.protocol = '<%= DockerClient.config['ws_client_protocol']&.match(/(\w+):*\/*/)&.to_a&.at(1) %>:';
// strip anchor if it is in the url
sockURL.hash = ''
sockURL.hash = '';
return sockURL.toString();
},

View File

@ -108,5 +108,5 @@ CommandSocket.prototype.flush = function() {
*/
CommandSocket.prototype.killWebSocket = function() {
this.websocket.flush();
this.websocket.close();
};
this.websocket.close(1000);
};