authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 00:18:51-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 00:18:51-07:00
logc6410d37d7ff1bdb65b38f0e9c30da392a4de804
tree91326c0f05ae82cf6eabc24b2cb4ba3fea9a05de
parentaca2afc0b5400e4cf88c42d59b214240833ed9cd
signature Signed by PGP key B5690EEEBB952194

refactor(shared): remove unused mention path serializer (#9990)


2 files changed, 1 insertions(+), 24 deletions(-)

packages/shared/src/composerTrigger.test.ts+1-15
......@@ -1,20 +1,6 @@
11import { describe, expect, it } from "vite-plus/test";
22
3import { serializeComposerFileLink, serializeComposerMentionPath } from "./composerTrigger.ts";
4
5describe("serializeComposerMentionPath", () => {
6 it("keeps simple mention paths unquoted", () => {
7 expect(serializeComposerMentionPath("src/index.ts")).toBe("src/index.ts");
8 });
9
10 it("quotes mention paths containing whitespace", () => {
11 expect(serializeComposerMentionPath("docs/My File.md")).toBe('"docs/My File.md"');
12 });
13
14 it("escapes quoted mention path content", () => {
15 expect(serializeComposerMentionPath('docs/My "File".md')).toBe('"docs/My \\"File\\".md"');
16 });
17});
3import { serializeComposerFileLink } from "./composerTrigger.ts";
184
195describe("serializeComposerFileLink", () => {
206 it("uses the basename as the markdown label", () => {
packages/shared/src/composerTrigger.ts-9
......@@ -8,15 +8,6 @@ export interface ComposerTrigger {
88 rangeEnd: number;
99}
1010
11const SIMPLE_MENTION_PATH_REGEX = /^[^\s@"\\]+$/;
12
13export function serializeComposerMentionPath(path: string): string {
14 if (SIMPLE_MENTION_PATH_REGEX.test(path)) {
15 return path;
16 }
17 return `"${path.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
18}
19
2011function composerFileLinkBasename(path: string): string {
2112 const separatorIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
2213 return separatorIndex >= 0 ? path.slice(separatorIndex + 1) : path;