@ceeblue/web-utils 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -496,6 +496,10 @@ declare class NetAddress {
496
496
  * console.log(NetAddress.fixProtocol('wss','http://domain/path')) // 'ws://domain/path'
497
497
  */
498
498
  static fixProtocol(protocol: string, address: string): string;
499
+ /**
500
+ * The host part from address `(http://)domain:port/path)`
501
+ */
502
+ get host(): string;
499
503
  /**
500
504
  * The domain part from address `(http://)domain(:port/path)`
501
505
  */
@@ -504,9 +508,6 @@ declare class NetAddress {
504
508
  * The port part from address `(http://)domain(:port/path)`, or defaultPort if passed in NetAddress constructor
505
509
  */
506
510
  get port(): number | undefined;
507
- /**
508
- * @returns the string address as passed in the constructor
509
- */
510
511
  toString(): string;
511
512
  /**
512
513
  * @returns the string address as passed in the constructor
@@ -515,6 +516,7 @@ declare class NetAddress {
515
516
  valueOf(): string;
516
517
  private _address;
517
518
  private _domain;
519
+ private _host;
518
520
  private _port?;
519
521
  /**
520
522
  * Build a NetAddress object and parse address
package/dist/web-utils.js CHANGED
@@ -1053,6 +1053,12 @@ class NetAddress {
1053
1053
  }
1054
1054
  return protocol + '://' + address;
1055
1055
  }
1056
+ /**
1057
+ * The host part from address `(http://)domain:port/path)`
1058
+ */
1059
+ get host() {
1060
+ return this._host;
1061
+ }
1056
1062
  /**
1057
1063
  * The domain part from address `(http://)domain(:port/path)`
1058
1064
  */
@@ -1065,9 +1071,6 @@ class NetAddress {
1065
1071
  get port() {
1066
1072
  return this._port;
1067
1073
  }
1068
- /**
1069
- * @returns the string address as passed in the constructor
1070
- */
1071
1074
  toString() {
1072
1075
  return this._address;
1073
1076
  }
@@ -1107,24 +1110,24 @@ class NetAddress {
1107
1110
  address = address.substring(1);
1108
1111
  } // else something else #/
1109
1112
  }
1113
+ // Remove Path!
1114
+ pos = address.indexOf('/');
1115
+ if (pos >= 0) {
1116
+ address = address.substring(0, pos);
1117
+ }
1118
+ this._host = address;
1110
1119
  this._domain = address;
1111
1120
  this._port = defaultPort;
1112
1121
  // Parse Port
1113
- pos = address.lastIndexOf(':');
1114
- if (pos >= 0) {
1122
+ pos = this._host.lastIndexOf(':');
1123
+ const endOfBrace = this._host.lastIndexOf(']'); // to support IPv6
1124
+ if (pos > endOfBrace) {
1115
1125
  const port = parseInt(address.substring(pos + 1));
1116
- if (port && port <= 0xffff) {
1126
+ if (port >= 0 && port <= 0xffff) {
1117
1127
  this._port = port;
1118
1128
  this._domain = address.substring(0, pos);
1119
1129
  }
1120
1130
  }
1121
- else {
1122
- // Remove Path!
1123
- pos = address.indexOf('/');
1124
- if (pos >= 0) {
1125
- this._domain = address.substring(0, pos);
1126
- }
1127
- }
1128
1131
  }
1129
1132
  }/**
1130
1133
  * Copyright 2024 Ceeblue B.V.
@@ -1232,7 +1235,7 @@ function buildURL(type, params, protocol = 'wss') {
1232
1235
  if (!params.streamName) {
1233
1236
  // extract the second part of the URL's path (the first part being the protocol name), or the first path if no other part exists
1234
1237
  const parts = url.pathname.split('/');
1235
- params.streamName = parts[2] || parts[1] || parts[0];
1238
+ params.streamName = getBaseFile(parts[2] || parts[1] || parts[0]);
1236
1239
  }
1237
1240
  }
1238
1241
  if (params.accessToken) {
@@ -2431,4 +2434,4 @@ class UIMetrics {
2431
2434
  * This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
2432
2435
  * See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
2433
2436
  */
2434
- const VERSION = '4.1.0';export{BinaryReader,BinaryWriter,BitReader,ByteRate,Connect,EpochTime,EventEmitter,FixMap,Log,LogLevel,Loggable,NetAddress,Numbers,Queue,SDP,UIMetrics,Util,VERSION,WebSocketReliable,log};//# sourceMappingURL=web-utils.js.map
2437
+ const VERSION = '4.2.0';export{BinaryReader,BinaryWriter,BitReader,ByteRate,Connect,EpochTime,EventEmitter,FixMap,Log,LogLevel,Loggable,NetAddress,Numbers,Queue,SDP,UIMetrics,Util,VERSION,WebSocketReliable,log};//# sourceMappingURL=web-utils.js.map