Skip to content

Commit 3f2c845

Browse files
juliusmarmingecodex
andcommitted
Reuse shared URL diagnostics
Co-authored-by: codex <[email protected]>
1 parent 2890d5c commit 3f2c845

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎apps/mobile/src/lib/composerImages.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
PROVIDER_SEND_TURN_MAX_IMAGE_BYTES,
44
type UploadChatImageAttachment,
55
} from "@t3tools/contracts";
6+
import { getUrlDiagnostics } from "@t3tools/shared/urlDiagnostics";
67
import * as Schema from "effect/Schema";
78
import { uuidv4 } from "./uuid";
89

@@ -298,15 +299,10 @@ export function isOwnedPastedImageUri(uri: string): boolean {
298299
}
299300

300301
function describeComposerImageUri(uri: string) {
301-
let uriProtocol: string | undefined;
302-
try {
303-
uriProtocol = new URL(uri).protocol || undefined;
304-
} catch {
305-
// Malformed URIs still retain a nonsecret input length for diagnostics.
306-
}
302+
const diagnostics = getUrlDiagnostics(uri);
307303
return {
308-
uriLength: uri.length,
309-
...(uriProtocol === undefined ? {} : { uriProtocol }),
304+
uriLength: diagnostics.inputLength,
305+
...(diagnostics.protocol === undefined ? {} : { uriProtocol: diagnostics.protocol }),
310306
};
311307
}
312308

0 commit comments

Comments
 (0)