Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

994 B
Raw Blame
import { ALL_REPOSITORIES, isAllowedRepository } from './repository';

describe('isAllowedRepository', () => {
  it.each([
    ['o/r', ['o/r'], true],
    ['O/R', ['o/r'], true],
    ['o/other', ['o/r'], false],
    ['o/other', ['o/*'], true],
    ['x/r', ['o/*'], false],
    ['o/r', [], false],
    ['g/sub/r', ['g/sub/r'], true],
    ['G/Sub/R', ['g/sub/*'], true],
    ['g/sub/r', ['g/*'], false],
    ['g/r', ['g/sub/*'], false],
    ['g/sub/r', ['g/sub'], false],
    ['o/r', undefined, false],
  ])('%s against %j is %s', (repo, allowed, expected) => {
    expect(isAllowedRepository(repo, allowed)).toBe(expected);
  });

  it('matches any repository for the opt-in list, and only for it', () => {
    expect(isAllowedRepository('any/thing', ALL_REPOSITORIES)).toBe(true);
    expect(isAllowedRepository('group/sub/thing', ALL_REPOSITORIES)).toBe(true);
    expect(isAllowedRepository('o/r', ['*/r'])).toBe(true);
    expect(isAllowedRepository('o/r', ['o/r2'])).toBe(false);
  });
});