Skip to content

Commit f4d89f8

Browse files
dedupe helper
1 parent 04e211a commit f4d89f8

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

‎apps/web/src/components/settings/ConnectionsSettings.tsx‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ import {
5252
revokeOtherServerClientSessions,
5353
revokeServerClientSession,
5454
revokeServerPairingLink,
55+
isLoopbackHostname,
5556
type ServerClientSessionRecord,
5657
type ServerPairingLinkRecord,
57-
} from "../../environments/primary";
58+
} from "~/environments/primary";
5859
import type { WsRpcClient } from "~/rpc/wsRpcClient";
5960
import {
6061
type SavedEnvironmentRecord,
@@ -65,7 +66,7 @@ import {
6566
getPrimaryEnvironmentConnection,
6667
reconnectSavedEnvironment,
6768
removeSavedEnvironment,
68-
} from "../../environments/runtime";
69+
} from "~/environments/runtime";
6970

7071
const accessTimestampFormatter = new Intl.DateTimeFormat(undefined, {
7172
dateStyle: "medium",
@@ -253,16 +254,6 @@ function resolveCurrentOriginPairingUrl(credential: string): string {
253254
return setPairingTokenOnUrl(url, credential).toString();
254255
}
255256

256-
function isLoopbackHostname(hostname: string): boolean {
257-
const normalized = hostname.trim().toLowerCase();
258-
return (
259-
normalized === "localhost" ||
260-
normalized === "127.0.0.1" ||
261-
normalized === "::1" ||
262-
normalized === "[::1]"
263-
);
264-
}
265-
266257
type PairingLinkListRowProps = {
267258
pairingLink: ServerPairingLinkRecord;
268259
endpointUrl: string | null | undefined;

‎apps/web/src/environments/primary/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ export {
3232
__resetServerAuthBootstrapForTests,
3333
} from "./auth";
3434

35-
export { resolvePrimaryEnvironmentHttpUrl } from "./target";
35+
export { resolvePrimaryEnvironmentHttpUrl, isLoopbackHostname } from "./target";

‎apps/web/src/environments/primary/target.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function normalizeHostname(hostname: string): string {
2323
.replace(/^\[(.*)\]$/, "$1");
2424
}
2525

26-
function isLoopbackHostname(hostname: string): boolean {
26+
export function isLoopbackHostname(hostname: string): boolean {
2727
return LOOPBACK_HOSTNAMES.has(normalizeHostname(hostname));
2828
}
2929

0 commit comments

Comments
 (0)