diff --git a/.pnp.cjs b/.pnp.cjs index dba34ef4b..f17af64f2 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -23562,11 +23562,13 @@ const RAW_RUNTIME_STATE = ["@swc/core-android-arm64", "npm:1.3.11"],\ ["@types/jest", "npm:27.5.2"],\ ["@types/node", "npm:20.3.1"],\ + ["@types/punycode", "npm:2.1.0"],\ ["eventemitter3", "npm:4.0.7"],\ ["jest", "virtual:5b1bfc01f31fc8b6df1fded8e5f8600ad6a5ba6fb856dd4c3f48e68ef9f706ff517b97c32734ea9c26a861e51644343d83dd80d269cfce72fcd0c8b877aae724#npm:27.5.1"],\ ["jest-fetch-mock", "npm:3.0.3"],\ ["jest-websocket-mock", "npm:2.4.0"],\ ["mock-socket", "npm:9.2.1"],\ + ["punycode", "npm:2.3.0"],\ ["reconnecting-websocket", "npm:4.4.0"],\ ["semver", "npm:7.5.4"],\ ["ts-jest", "virtual:5b1bfc01f31fc8b6df1fded8e5f8600ad6a5ba6fb856dd4c3f48e68ef9f706ff517b97c32734ea9c26a861e51644343d83dd80d269cfce72fcd0c8b877aae724#npm:27.1.5"],\ diff --git a/packages/client/src/components/MkAutocomplete.vue b/packages/client/src/components/MkAutocomplete.vue index d61dafc0d..955feab16 100644 --- a/packages/client/src/components/MkAutocomplete.vue +++ b/packages/client/src/components/MkAutocomplete.vue @@ -255,10 +255,10 @@ function exec() { users.value = JSON.parse(cache); fetching.value = false; } else { - const acct = Acct.parse(props.q); + const acct = Acct.parse(props.q); os.api("users/search-by-username-and-host", { username: acct.username, - host: acct.host ?? undefined, + host: acct.host ?? undefined, limit: 10, detail: false, }).then((searchedUsers) => { diff --git a/packages/client/src/components/global/MkAcct.vue b/packages/client/src/components/global/MkAcct.vue index 896731847..2d6c96ebc 100644 --- a/packages/client/src/components/global/MkAcct.vue +++ b/packages/client/src/components/global/MkAcct.vue @@ -4,7 +4,7 @@ @{{ user.host || host }}@{{ user.host ? toUnicode(user.host) : host }} diff --git a/packages/trashposs-js/package.json b/packages/trashposs-js/package.json index 1f690d6a7..23d3a316f 100644 --- a/packages/trashposs-js/package.json +++ b/packages/trashposs-js/package.json @@ -28,10 +28,12 @@ "@swc/core": "^1.3.62", "@types/jest": "^27.4.0", "@types/node": "20.3.1", + "@types/punycode": "2.1.0", "jest": "^27.4.5", "jest-fetch-mock": "^3.0.3", "jest-websocket-mock": "^2.2.1", "mock-socket": "^9.0.8", + "punycode": "2.3.0", "ts-jest": "^27.1.2", "ts-node": "10.4.0", "tsd": "^0.28.1", diff --git a/packages/trashposs-js/src/acct.ts b/packages/trashposs-js/src/acct.ts index cb6808b4b..e92904fe6 100644 --- a/packages/trashposs-js/src/acct.ts +++ b/packages/trashposs-js/src/acct.ts @@ -1,3 +1,5 @@ +import { toASCII, toUnicode } from "punycode/"; + export type Acct = { username: string; host: string | null; @@ -6,9 +8,9 @@ export type Acct = { export function parse(acct: string): Acct { if (acct.startsWith("@")) acct = acct.slice(1); const split = acct.split("@", 2); - return { username: split[0], host: split[1] || null }; + return { username: split[0], host: (split[1] ? toASCII(split[1]) : split[1]) || null }; } export function toString(acct: Acct): string { - return acct.host == null ? acct.username : `${acct.username}@${acct.host}`; + return acct.host == null ? acct.username : `${acct.username}@${(acct.host ? toUnicode(acct.host) : acct.host)}`; } diff --git a/yarn.lock b/yarn.lock index 2f6595a56..d8f95b5f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19834,11 +19834,13 @@ __metadata: "@swc/core-android-arm64": "npm:1.3.11" "@types/jest": "npm:^27.4.0" "@types/node": "npm:20.3.1" + "@types/punycode": "npm:2.1.0" eventemitter3: "npm:^4.0.7" jest: "npm:^27.4.5" jest-fetch-mock: "npm:^3.0.3" jest-websocket-mock: "npm:^2.2.1" mock-socket: "npm:^9.0.8" + punycode: "npm:2.3.0" reconnecting-websocket: "npm:^4.4.0" semver: "npm:^7.3.8" ts-jest: "npm:^27.1.2"