Skip to content

Commit 316cc7a

Browse files
juliusmarmingecodex
andcommitted
Preserve raw external URL input length
Co-authored-by: codex <[email protected]>
1 parent df4b2f5 commit 316cc7a

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎apps/desktop/src/electron/ElectronShell.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("ElectronShell", () => {
5151
const cause = new Error("open failed");
5252
openExternalMock.mockRejectedValue(cause);
5353
const externalUrl =
54-
"https://user:[email protected]/signed-secret-token/path?access_token=secret#fragment";
54+
"HTTPS://user:[email protected]:443/signed-secret-token/path?access_token=secret#fragment";
5555

5656
const electronShell = yield* ElectronShell.ElectronShell;
5757
const error = yield* Effect.flip(electronShell.openExternal(externalUrl));

‎apps/desktop/src/electron/ElectronShell.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export function parseSafeExternalUrl(rawUrl: unknown): Option.Option<string> {
5555
}
5656
}
5757

58-
function describeExternalUrl(externalUrl: string) {
58+
function describeExternalUrl(externalUrl: string, inputLength: number) {
5959
const diagnostics = getUrlDiagnostics(externalUrl);
6060
return {
6161
urlHostname: diagnostics.hostname ?? "",
62-
urlLength: diagnostics.inputLength,
62+
urlLength: inputLength,
6363
urlProtocol: diagnostics.protocol ?? "",
6464
};
6565
}
@@ -75,19 +75,22 @@ export class ElectronShell extends Context.Service<
7575
>()("@t3tools/desktop/electron/ElectronShell") {}
7676

7777
export const make = ElectronShell.of({
78-
openExternal: (rawUrl) =>
79-
Option.match(parseSafeExternalUrl(rawUrl), {
78+
openExternal: (rawUrl) => {
79+
const inputLength = typeof rawUrl === "string" ? rawUrl.length : 0;
80+
81+
return Option.match(parseSafeExternalUrl(rawUrl), {
8082
onNone: () => Effect.succeed(false),
8183
onSome: (externalUrl) =>
8284
Effect.tryPromise({
8385
try: () => Electron.shell.openExternal(externalUrl),
8486
catch: (cause) =>
8587
new ElectronShellOpenExternalError({
86-
...describeExternalUrl(externalUrl),
88+
...describeExternalUrl(externalUrl, inputLength),
8789
cause,
8890
}),
8991
}).pipe(Effect.as(true)),
90-
}),
92+
});
93+
},
9194
copyText: (text) =>
9295
Effect.try({
9396
try: () => Electron.clipboard.writeText(text),

0 commit comments

Comments
 (0)