import assert from "node:assert/strict"; import test from "node:test"; import { isChatGptSharePath, validateChatGptShareUrl } from "../dist/url.js"; test("accepts current ChatGPT post share URLs", () => { const source = "https://chatgpt.com/s/t_6a5f58aa36d08191b4d794e9aac88146"; assert.equal(validateChatGptShareUrl(source), source); assert.equal(isChatGptSharePath("/s/t_6a5f58aa36d08191b4d794e9aac88146"), true); }); test("keeps accepting legacy ChatGPT share URLs", () => { assert.equal( validateChatGptShareUrl("https://chatgpt.com/share/12345678-abcd-4321-abcd-1234567890ab"), "https://chatgpt.com/share/12345678-abcd-4321-abcd-1234567890ab" ); assert.equal( validateChatGptShareUrl("https://chat.openai.com/share/12345678-abcd-4321-abcd-1234567890ab"), "https://chat.openai.com/share/12345678-abcd-4321-abcd-1234567890ab" ); }); test("rejects non-share and deceptive ChatGPT paths", () => { for (const source of [ "https://chatgpt.com/s/example", "https://chatgpt.com/sharex/example", "https://chatgpt.com/share/example/extra", "https://example.com/s/t_6a5f58aa36d08191b4d794e9aac88146" ]) { assert.throws(() => validateChatGptShareUrl(source), /Only public ChatGPT share URLs/); } });