Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(source-control): keep clipped repository error details valid Unicode #48286

Opensaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48286/headopened View on GitHub

Showing 2 changed files with 30 additions and 1 deletion.

x
0 of 2 viewed, 2 left
19 additions and 0 deletionspackages/source-control-core/src/server/SourceControlProvider.test.tsModified
View file
@@ -1,6 +1,7 @@
import { assert, it } from "@effect/vitest";
​
import {
+ repositoryNotFoundDetail,
repositoryPathFromRemoteUrl,
transportSafeSourceControlErrorValue,
} from "./SourceControlProvider.ts";
@@ -14,6 +15,24 @@
);
});
​
+it("keeps clipped repository error details valid Unicode across surrogate boundaries", () => {
+ const straddling = `team/${"a".repeat(250)}🚀`;
+ const clipped = transportSafeSourceControlErrorValue(straddling);
+ assert.strictEqual(clipped, `team/${"a".repeat(250)}`);
+ assert.isTrue(clipped.isWellFormed());
+​
+ const detail = repositoryNotFoundDetail(straddling);
+ assert.isTrue(detail.isWellFormed());
+ assert.strictEqual(
+ new TextDecoder().decode(new TextEncoder().encode(detail)),
+ `Repository team/${"a".repeat(250)} was not found. Check the owner and name and try again.`,
+ );
+​
+ const exactFit = `team/${"a".repeat(249)}🚀`;
+ assert.strictEqual(transportSafeSourceControlErrorValue(exactFit), exactFit);
+ assert.strictEqual(transportSafeSourceControlErrorValue(`${exactFit}x`), exactFit);
+});
+​