feat: Update check against pi.dev (#3877)

This commit is contained in:
Armin Ronacher
2026-04-28 12:48:27 +02:00
committed by GitHub
parent 4166cfa921
commit c745efc0d0
9 changed files with 216 additions and 28 deletions

View File

@@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest";
import { getPiUserAgent } from "../src/utils/pi-user-agent.js";
describe("getPiUserAgent", () => {
it("formats the user agent expected by pi.dev", () => {
const runtime = process.versions.bun ? `bun/${process.versions.bun}` : `node/${process.version}`;
const userAgent = getPiUserAgent("1.2.3");
expect(userAgent).toBe(`pi/1.2.3 (${process.platform}; ${runtime}; ${process.arch})`);
expect(userAgent).toMatch(/^pi\/[^\s()]+ \([^;()]+;\s*[^;()]+;\s*[^()]+\)$/);
});
});