Skip to content

Commit

Permalink
Merge pull request #2972 from Onek8/main
Browse files Browse the repository at this point in the history
Update WebSocket and replace Regex
  • Loading branch information
luboslenco authored Nov 29, 2023
2 parents 8a2c13a + a7cdc15 commit 70fce1f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Sources/armory/network/WebSocket.hx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ class WebSocket extends WebSocketCommon {
}

inline private function parseUrl(url)
{
{
/** TO DO - FIND OUT WHAT IS BREAKING REGEX IN THE NEW PCRE2 FOR HL C
var urlRegExp = ~/^(\w+?):\/\/([\w\.-]+)(:(\d+))?(\/.*)?$/;
if ( ! urlRegExp.match(url)) {
Expand All @@ -209,9 +211,24 @@ class WebSocket extends WebSocketCommon {
if (_path == null || _path.length == 0) {
_path = "/";
}

**/
var urlArr = url.split(":");
if ( urlArr.length < 3) {
throw 'Uri not matching websocket URL "${url}"';
}
_protocol = urlArr[0];
_host = urlArr[1].substr(2, urlArr[1].length);
var parsedPort = Std.parseInt(urlArr[2].split("/")[0]);
if (parsedPort > 0 ) {
_port = parsedPort;
}
_path = urlArr[2].substr(urlArr[2].split("/")[0].length, urlArr[2].length);
if (_path == null || _path.length == 0) {
_path = "/";
}
}


private function createSocket():SocketImpl
{
if (_protocol == "wss") {
Expand Down

0 comments on commit 70fce1f

Please sign in to comment.