pmcf 6.65.5 → 6.66.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/endpoint.mjs +19 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.65.5",
3
+ "version": "6.66.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/endpoint.mjs CHANGED
@@ -174,7 +174,8 @@ export class DomainNameEndpoint extends PortEndpoint {
174
174
  export class HTTPEndpoint extends BaseEndpoint {
175
175
  static name = "url_endpoint";
176
176
  static attributes = {
177
- url: url_attribute
177
+ url: url_attribute,
178
+ addressType: { ...string_attribute, name: "addressType" }
178
179
  };
179
180
 
180
181
  static {
@@ -199,21 +200,22 @@ export class HTTPEndpoint extends BaseEndpoint {
199
200
  } else if (address instanceof URL) {
200
201
  this.url = address;
201
202
  } else {
203
+ this.networkAddress = address;
202
204
  this.family = data.family ?? address.family;
203
205
 
204
- const scheme = data.scheme ?
205
- `${data.scheme}://` :
206
- (data.tls ? "https://" : "http://");
207
-
208
- this.url = new URL(scheme +
209
- (data.family === FAMILY_IPV6
210
- ? "[" + address.address + "]"
211
- : address.address) +
212
- ":" +
213
- data.port +
214
- (data.pathname ?? "/")
206
+ const scheme = data.scheme ? data.scheme : data.tls ? "https" : "http";
207
+
208
+ const domainName = [...address.domainNames][0];
209
+ const hostname =
210
+ domainName ??
211
+ (data.family === FAMILY_IPV6
212
+ ? "[" + address.address + "]"
213
+ : address.address);
214
+
215
+ this.url = new URL(
216
+ `${scheme}://${hostname}:${data.port}` + (data.pathname ?? "/")
215
217
  );
216
- this.hostname = address.address;
218
+ this.hostname = domainName ?? address.address;
217
219
  }
218
220
  }
219
221
 
@@ -240,6 +242,10 @@ export class HTTPEndpoint extends BaseEndpoint {
240
242
  return PROTOCOL_TCP;
241
243
  }
242
244
 
245
+ get addressType() {
246
+ return this.networkAddress?.type;
247
+ }
248
+
243
249
  get tls() {
244
250
  return this.url.toString().startsWith("https:");
245
251
  }