Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

741 B
Raw Blame
import { HTTPException } from "hono/http-exception";
import {
  assertGitlabTransport,
  normalizeGitlabBaseUrl,
  normalizeProjectPath,
} from "../../plugins/gitlab/config";

function orBadRequest<T>(normalize: () => T): T {
  try {
    return normalize();
  } catch (error) {
    throw new HTTPException(400, {
      message: error instanceof Error ? error.message : "Invalid GitLab input",
    });
  }
}

export function parseGitlabBaseUrl(url: string): string {
  return orBadRequest(() => {
    const normalized = normalizeGitlabBaseUrl(url);
    assertGitlabTransport(normalized);
    return normalized;
  });
}

export function parseGitlabProjectPath(path: string): string {
  return orBadRequest(() => normalizeProjectPath(path));
}