reviewUrl

tcmts.cli.sync.reviewUrl · #i4pp6oul · term · runs anywhere

The review page for a contribution on an HTTP remote (with the token in its fragment), if it is one.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import type { RemoteConfig } from "#codebase/tcmts/cli/sync";

export function reviewUrl(cb: Codebase, remote: string, id?: number): string | undefined {
  const configured = cb.store.getSetting(`remote.${remote}`);
  if (!configured) return undefined;
  const c = JSON.parse(configured) as RemoteConfig;
  if (!c.url.startsWith("http")) return undefined;
  return `${c.url.replace(/\/$/, "")}/forge/contributions${id === undefined ? "" : `/${id}`}${c.token ? `#token=${encodeURIComponent(c.token)}` : ""}`;
}

uses

used by