@telorun/debug-ui 0.2.0 → 0.2.1
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.
package/package.json
CHANGED
package/src/endpoints.ts
CHANGED
|
@@ -21,8 +21,18 @@ export function endpointHref(endpoint: AppEndpoint): string | null {
|
|
|
21
21
|
return `http://${formatHost(endpoint.host)}:${endpoint.port}`;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/** Display label for an endpoint, e.g. `localhost:8080` or `:9000/udp`.
|
|
24
|
+
/** Display label for an endpoint, e.g. `localhost:8080` or `:9000/udp`. When the
|
|
25
|
+
* endpoint carries an absolute `url`, label with that url's authority so the text
|
|
26
|
+
* matches the link actually opened — `host`/`port` may be display-only values
|
|
27
|
+
* (e.g. a proxy/ingress whose `host` isn't itself routable). */
|
|
25
28
|
export function endpointLabel(endpoint: AppEndpoint): string {
|
|
29
|
+
if (endpoint.url) {
|
|
30
|
+
try {
|
|
31
|
+
return new URL(endpoint.url).host;
|
|
32
|
+
} catch {
|
|
33
|
+
// Malformed url — fall back to host:port below.
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
const host = endpoint.host ? formatHost(endpoint.host) : "";
|
|
27
37
|
const base = `${host}:${endpoint.port}`;
|
|
28
38
|
return endpoint.protocol === "tcp" ? base : `${base}/udp`;
|