Unverified Commit 94cbc27f authored by Hong Minhee (洪 民憙)'s avatar Hong Minhee (洪 民憙) Committed by GitHub
Browse files

Merge pull request #214 from frodi-karlsson/1.0-maintenance

Change from "node:punycode" to "node:url"
parents 8bb07bfc 9a8a8fc2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
import { toASCII, toUnicode } from "node:punycode";
import { domainToASCII, domainToUnicode } from "node:url";
import { lookupWebFinger } from "../webfinger/lookup.ts";
import { Application, Group, Organization, Person, Service } from "./vocab.ts";

@@ -190,7 +190,7 @@ export function normalizeActorHandle(
    throw new TypeError("Invalid actor handle.");
  }
  domain = domain.toLowerCase();
  domain = options.punycode ? toASCII(domain) : toUnicode(domain);
  domain = options.punycode ? domainToASCII(domain) : domainToUnicode(domain);
  domain = domain.toLowerCase();
  const user = handle.substring(0, atPos);
  return options.trimLeadingAt ? `${user}@${domain}` : `@${user}@${domain}`;
+4 −2
Original line number Diff line number Diff line
import { getLogger } from "@logtape/logtape";
import { toASCII } from "node:punycode";
import { domainToASCII } from "node:url";
import type {
  ActorDispatcher,
  ActorHandleMapper,
@@ -74,7 +74,9 @@ export async function handleWebFinger<TContextData>(
  const uriParsed = context.parseUri(resourceUrl);
  if (uriParsed?.type != "actor") {
    const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
    if (match == null || toASCII(match[2].toLowerCase()) != context.url.host) {
    if (
      match == null || domainToASCII(match[2].toLowerCase()) != context.url.host
    ) {
      return await onNotFound(request);
    }
    const username = match[1];