mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-21 16:33:48 +01:00
Improve punycode handling
This commit is contained in:
parent
3b52022d9d
commit
5de9e82a18
2
.pnp.cjs
generated
2
.pnp.cjs
generated
@ -23562,11 +23562,13 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@swc/core-android-arm64", "npm:1.3.11"],\
|
["@swc/core-android-arm64", "npm:1.3.11"],\
|
||||||
["@types/jest", "npm:27.5.2"],\
|
["@types/jest", "npm:27.5.2"],\
|
||||||
["@types/node", "npm:20.3.1"],\
|
["@types/node", "npm:20.3.1"],\
|
||||||
|
["@types/punycode", "npm:2.1.0"],\
|
||||||
["eventemitter3", "npm:4.0.7"],\
|
["eventemitter3", "npm:4.0.7"],\
|
||||||
["jest", "virtual:5b1bfc01f31fc8b6df1fded8e5f8600ad6a5ba6fb856dd4c3f48e68ef9f706ff517b97c32734ea9c26a861e51644343d83dd80d269cfce72fcd0c8b877aae724#npm:27.5.1"],\
|
["jest", "virtual:5b1bfc01f31fc8b6df1fded8e5f8600ad6a5ba6fb856dd4c3f48e68ef9f706ff517b97c32734ea9c26a861e51644343d83dd80d269cfce72fcd0c8b877aae724#npm:27.5.1"],\
|
||||||
["jest-fetch-mock", "npm:3.0.3"],\
|
["jest-fetch-mock", "npm:3.0.3"],\
|
||||||
["jest-websocket-mock", "npm:2.4.0"],\
|
["jest-websocket-mock", "npm:2.4.0"],\
|
||||||
["mock-socket", "npm:9.2.1"],\
|
["mock-socket", "npm:9.2.1"],\
|
||||||
|
["punycode", "npm:2.3.0"],\
|
||||||
["reconnecting-websocket", "npm:4.4.0"],\
|
["reconnecting-websocket", "npm:4.4.0"],\
|
||||||
["semver", "npm:7.5.4"],\
|
["semver", "npm:7.5.4"],\
|
||||||
["ts-jest", "virtual:5b1bfc01f31fc8b6df1fded8e5f8600ad6a5ba6fb856dd4c3f48e68ef9f706ff517b97c32734ea9c26a861e51644343d83dd80d269cfce72fcd0c8b877aae724#npm:27.1.5"],\
|
["ts-jest", "virtual:5b1bfc01f31fc8b6df1fded8e5f8600ad6a5ba6fb856dd4c3f48e68ef9f706ff517b97c32734ea9c26a861e51644343d83dd80d269cfce72fcd0c8b877aae724#npm:27.1.5"],\
|
||||||
|
@ -255,10 +255,10 @@ function exec() {
|
|||||||
users.value = JSON.parse(cache);
|
users.value = JSON.parse(cache);
|
||||||
fetching.value = false;
|
fetching.value = false;
|
||||||
} else {
|
} else {
|
||||||
const acct = Acct.parse(props.q);
|
const acct = Acct.parse(props.q);
|
||||||
os.api("users/search-by-username-and-host", {
|
os.api("users/search-by-username-and-host", {
|
||||||
username: acct.username,
|
username: acct.username,
|
||||||
host: acct.host ?? undefined,
|
host: acct.host ?? undefined,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
detail: false,
|
detail: false,
|
||||||
}).then((searchedUsers) => {
|
}).then((searchedUsers) => {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="user.host || detail || $store.state.showFullAcct"
|
v-if="user.host || detail || $store.state.showFullAcct"
|
||||||
class="host"
|
class="host"
|
||||||
>@{{ user.host || host }}</span
|
>@{{ user.host ? toUnicode(user.host) : host }}</span
|
||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
"@swc/core": "^1.3.62",
|
"@swc/core": "^1.3.62",
|
||||||
"@types/jest": "^27.4.0",
|
"@types/jest": "^27.4.0",
|
||||||
"@types/node": "20.3.1",
|
"@types/node": "20.3.1",
|
||||||
|
"@types/punycode": "2.1.0",
|
||||||
"jest": "^27.4.5",
|
"jest": "^27.4.5",
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"jest-websocket-mock": "^2.2.1",
|
"jest-websocket-mock": "^2.2.1",
|
||||||
"mock-socket": "^9.0.8",
|
"mock-socket": "^9.0.8",
|
||||||
|
"punycode": "2.3.0",
|
||||||
"ts-jest": "^27.1.2",
|
"ts-jest": "^27.1.2",
|
||||||
"ts-node": "10.4.0",
|
"ts-node": "10.4.0",
|
||||||
"tsd": "^0.28.1",
|
"tsd": "^0.28.1",
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { toASCII, toUnicode } from "punycode/";
|
||||||
|
|
||||||
export type Acct = {
|
export type Acct = {
|
||||||
username: string;
|
username: string;
|
||||||
host: string | null;
|
host: string | null;
|
||||||
@ -6,9 +8,9 @@ export type Acct = {
|
|||||||
export function parse(acct: string): Acct {
|
export function parse(acct: string): Acct {
|
||||||
if (acct.startsWith("@")) acct = acct.slice(1);
|
if (acct.startsWith("@")) acct = acct.slice(1);
|
||||||
const split = acct.split("@", 2);
|
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 {
|
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)}`;
|
||||||
}
|
}
|
||||||
|
@ -19834,11 +19834,13 @@ __metadata:
|
|||||||
"@swc/core-android-arm64": "npm:1.3.11"
|
"@swc/core-android-arm64": "npm:1.3.11"
|
||||||
"@types/jest": "npm:^27.4.0"
|
"@types/jest": "npm:^27.4.0"
|
||||||
"@types/node": "npm:20.3.1"
|
"@types/node": "npm:20.3.1"
|
||||||
|
"@types/punycode": "npm:2.1.0"
|
||||||
eventemitter3: "npm:^4.0.7"
|
eventemitter3: "npm:^4.0.7"
|
||||||
jest: "npm:^27.4.5"
|
jest: "npm:^27.4.5"
|
||||||
jest-fetch-mock: "npm:^3.0.3"
|
jest-fetch-mock: "npm:^3.0.3"
|
||||||
jest-websocket-mock: "npm:^2.2.1"
|
jest-websocket-mock: "npm:^2.2.1"
|
||||||
mock-socket: "npm:^9.0.8"
|
mock-socket: "npm:^9.0.8"
|
||||||
|
punycode: "npm:2.3.0"
|
||||||
reconnecting-websocket: "npm:^4.4.0"
|
reconnecting-websocket: "npm:^4.4.0"
|
||||||
semver: "npm:^7.3.8"
|
semver: "npm:^7.3.8"
|
||||||
ts-jest: "npm:^27.1.2"
|
ts-jest: "npm:^27.1.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user