Commit 6f0121dd authored by ChanHaeng Lee's avatar ChanHaeng Lee
Browse files

Rename convertFediverseHandle to toAcctUrl

parent 2a7b461d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
import { Command } from "@cliffy/command";
import { convertFediverseHandle } from "@fedify/fedify/vocab";
import { toAcctUrl } from "@fedify/fedify/vocab";
import { lookupWebFinger } from "@fedify/fedify/webfinger";
import ora from "ora";
import { printJson } from "./utils.ts";
@@ -102,6 +102,6 @@ class NotFoundError extends Error {
 * ```
 */
function convertHandleToUrl(handle: string): URL {
  return convertFediverseHandle(handle) ?? // Convert the handle to a URL
  return toAcctUrl(handle) ?? // Convert the handle to a URL
    new InvalidHandleError(handle).throw(); // or throw an error if invalid
}
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ export function isFediverseHandle(
 * console.log(identifier?.href); // "acct:username@example.com"
 * ```
 */
export function convertFediverseHandle(handle: string): URL | null {
export function toAcctUrl(handle: string): URL | null {
  const parsed = parseFediverseHandle(handle);
  if (!parsed) return null;
  const identifier = new URL(`acct:${parsed.username}@${parsed.host}`);
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import {
  type GetUserAgentOptions,
} from "../runtime/docloader.ts";
import { lookupWebFinger } from "../webfinger/lookup.ts";
import { convertFediverseHandle } from "./handle.ts";
import { toAcctUrl } from "./handle.ts";
import { getTypeId } from "./type.ts";
import { type Collection, type Link, Object } from "./vocab.ts";

@@ -128,7 +128,7 @@ async function lookupObjectInternal(
  const documentLoader = options.documentLoader ??
    getDocumentLoader({ userAgent: options.userAgent });
  if (typeof identifier === "string") {
    identifier = convertFediverseHandle(identifier) ?? new URL(identifier);
    identifier = toAcctUrl(identifier) ?? new URL(identifier);
  }
  let document: unknown | null = null;
  if (identifier.protocol === "http:" || identifier.protocol === "https:") {