Skip to content

Commit 70e9b69

Browse files
juliusmarmingecodex
andcommitted
Reuse shared URL diagnostics
Co-authored-by: codex <[email protected]>
1 parent fc2f26e commit 70e9b69

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

‎apps/web/src/localApi.ts‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ContextMenuItem, LocalApi } from "@t3tools/contracts";
2+
import { getUrlDiagnostics } from "@t3tools/shared/urlDiagnostics";
23
import * as Schema from "effect/Schema";
34

45
import { resetRequestLatencyStateForTests } from "./rpc/requestLatencyState";
@@ -56,19 +57,11 @@ export class LocalApiUnavailableError extends Schema.TaggedErrorClass<LocalApiUn
5657
}
5758

5859
function describeExternalUrl(url: string) {
59-
let urlHostname: string | null = null;
60-
let urlProtocol: string | null = null;
61-
try {
62-
const parsed = new URL(url);
63-
urlHostname = parsed.hostname || null;
64-
urlProtocol = parsed.protocol || null;
65-
} catch {
66-
// Invalid URLs still retain their nonsecret input length for diagnostics.
67-
}
60+
const diagnostics = getUrlDiagnostics(url);
6861
return {
69-
urlHostname,
70-
urlLength: url.length,
71-
urlProtocol,
62+
urlHostname: diagnostics.hostname ?? null,
63+
urlLength: diagnostics.inputLength,
64+
urlProtocol: diagnostics.protocol ?? null,
7265
};
7366
}
7467

0 commit comments

Comments
 (0)