Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

771 B
Raw Blame
import { describe, expect, it } from 'vitest';

import { isGitHubUrl } from './isGitHubUrl';

describe('isGitHubUrl', () => {
  it.each([
    'https://github.com/lobehub/lobehub',
    'https://www.github.com/lobehub/lobehub',
    'https://gist.github.com/example',
  ])('accepts GitHub hosts: %s', (url) => {
    expect(isGitHubUrl(url)).toBe(true);
  });

  it.each([
    'https://evilgithub.com/lobehub/lobehub',
    'https://github.com.evil.example/lobehub/lobehub',
    'https://[email protected]/lobehub/lobehub',
  ])('rejects hosts that only contain github.com: %s', (url) => {
    expect(isGitHubUrl(url)).toBe(false);
  });

  it.each([undefined, '', 'not-a-url'])('rejects invalid URLs: %s', (url) => {
    expect(isGitHubUrl(url)).toBe(false);
  });
});