




















@@ -397,7 +397,7 @@ describe("diffs tool", () => {
397397});
398398399399const viewerPath = String((result?.details as Record<string, unknown>).viewerPath);
400-const [id] = viewerPath.split("/").filter(Boolean).slice(-2);
400+const id = extractViewerArtifactId(viewerPath);
401401const html = await store.readHtml(id);
402402expect(html).toContain('body data-theme="light"');
403403expect(html).toContain("--diffs-font-size: 17px;");
@@ -446,7 +446,7 @@ describe("diffs tool", () => {
446446expect((result?.details as Record<string, unknown>).fileScale).toBe(2.75);
447447expect((result?.details as Record<string, unknown>).fileMaxWidth).toBe(1320);
448448const viewerPath = String((result?.details as Record<string, unknown>).viewerPath);
449-const [id] = viewerPath.split("/").filter(Boolean).slice(-2);
449+const id = extractViewerArtifactId(viewerPath);
450450const html = await store.readHtml(id);
451451expect(html).toContain('body data-theme="dark"');
452452});
@@ -580,6 +580,22 @@ function readDetails(result: unknown): Record<string, unknown> {
580580return details;
581581}
582582583+function extractViewerArtifactId(viewerPath: string): string {
584+let previousSegment: string | undefined;
585+let currentSegment: string | undefined;
586+for (const segment of viewerPath.split("/")) {
587+if (segment.length === 0) {
588+continue;
589+}
590+previousSegment = currentSegment;
591+currentSegment = segment;
592+}
593+if (!previousSegment) {
594+throw new Error(`Missing artifact id in viewer path: ${viewerPath}`);
595+}
596+return previousSegment;
597+}
598+583599function readParametersProperties(parameters: unknown): Record<string, unknown> {
584600if (isRecord(parameters) && isRecord(parameters.properties)) {
585601return parameters.properties;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。