Skip to content

A desktop coding agent with free access to frontier models.

TypeScript
615 B
Raw Blame
export function getComparablePathname(target: string | null | undefined): string | null {
  const trimmed = target?.trim();
  if (!trimmed) {
    return null;
  }

  if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
    try {
      return new URL(trimmed).pathname;
    } catch {
      return trimmed;
    }
  }

  return trimmed.split(/[?#]/)[0] ?? trimmed;
}

export function isSamePathname(currentPathname: string, target: string | null | undefined) {
  const comparable = getComparablePathname(target);
  if (!comparable) {
    return false;
  }

  return comparable === currentPathname;
}