URL incorrectly encoded

Hello guys,

I am trying to configure my Vaadin Application (version 7.7.15) to support IPv6 and somehow the URL is encoded incorrectly.

For example: If the ip is: fd71:2d5a:e15a:1ed3::1, on browser you access it like this: http://[fd71:2d5a:e15a:1ed3::1]
.

The problem is that the character ‘[’ is replaced with ‘%5B’
and the character ‘]’ is replaced with ‘%5D’.

This encoding cause a "Failed to construct WebSocket: The URL is invalid; JavaScriptException [SyntaxError]
" as the picture is describing.

But if I modify the @Push annotation
from
@Push(transport = Transport.WEBSOCKET_XHR)
to
@Push(transport = Transport.LONG_POLLING), I am able to access the UI, but the API Calls are very very slow.

Can anyone tell me please how can I escape those characters from been encoded?

Thank you,
George

17516413.png

UPDATE:

I’ve found where the URL is encoded: in vaadin-push library(version 7.7.16), vaadinPush.debug.js file.

The method is called _buildWebSocketUrl

function _buildWebSocketUrl() {
                return _attachHeaders(_request, atmosphere.util.getAbsoluteURL(_request.webSocketUrl || _request.url)).replace(/^http/, "ws");
            }

which calls getAbsoluteURL method

  getAbsoluteURL: function (url) {
            if (typeof (document.createElement) === 'undefined') {
                // assuming the url to be already absolute when DOM is not supported
                return url;
            }
            var div = document.createElement("div");

            // Uses an innerHTML property to obtain an absolute URL
            div.innerHTML = '<a href="' + url + '"/>';

            // encodeURI and decodeURI are needed to normalize URL between IE and non-IE,
            // since IE doesn't encode the href property value and return it - http://jsfiddle.net/Yq9M8/1/
            return encodeURI(decodeURI(div.firstChild.href));
        }

which calls these functions ‘encodeURI’ and ‘decodeURI’.