fix: decode IDN domain name to Unicode (#3486)
This commit is contained in:
parent
e55f11b942
commit
b444e29387
3 changed files with 15 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import type { mastodon } from 'masto'
|
||||
import punycode from 'punycode/'
|
||||
|
||||
const { card, smallPictureOnly } = defineProps<{
|
||||
card: mastodon.v1.PreviewCard
|
||||
|
|
@ -19,7 +20,7 @@ const isSquare = computed(() => (
|
|||
|| Number(card.width || 0) < ogImageWidth
|
||||
|| Number(card.height || 0) < ogImageWidth / 2
|
||||
))
|
||||
const providerName = computed(() => card.providerName ? card.providerName : new URL(card.url).hostname)
|
||||
const providerName = computed(() => card.providerName ? card.providerName : punycode.toUnicode(new URL(card.url).hostname))
|
||||
|
||||
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
||||
const cardTypeIconMap: Record<mastodon.v1.PreviewCardType, string> = {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
"@tiptap/starter-kit": "2.27.1",
|
||||
"@tiptap/suggestion": "2.27.1",
|
||||
"@tiptap/vue-3": "2.27.1",
|
||||
"@types/punycode": "^2.1.4",
|
||||
"@unhead/schema": "^2.0.17",
|
||||
"@unlazy/nuxt": "^0.12.4",
|
||||
"@unocss/nuxt": "^66.5.2",
|
||||
|
|
@ -105,6 +106,7 @@
|
|||
"postcss-nested": "^7.0.0",
|
||||
"prosemirror-highlight": "^0.13.0",
|
||||
"prosemirror-state": "^1.4.3",
|
||||
"punycode": "^2.3.1",
|
||||
"rollup-plugin-node-polyfills": "^0.2.1",
|
||||
"shiki": "^1.22.2",
|
||||
"simple-git": "^3.19.1",
|
||||
|
|
|
|||
|
|
@ -104,6 +104,9 @@ importers:
|
|||
'@tiptap/vue-3':
|
||||
specifier: 2.27.1
|
||||
version: 2.27.1(@tiptap/core@2.27.1(@tiptap/pm@2.27.1))(@tiptap/pm@2.27.1)(vue@3.5.22(typescript@5.9.2))
|
||||
'@types/punycode':
|
||||
specifier: ^2.1.4
|
||||
version: 2.1.4
|
||||
'@unhead/schema':
|
||||
specifier: ^2.0.17
|
||||
version: 2.0.17
|
||||
|
|
@ -230,6 +233,9 @@ importers:
|
|||
prosemirror-state:
|
||||
specifier: ^1.4.3
|
||||
version: 1.4.3
|
||||
punycode:
|
||||
specifier: ^2.3.1
|
||||
version: 2.3.1
|
||||
rollup-plugin-node-polyfills:
|
||||
specifier: ^0.2.1
|
||||
version: 0.2.1
|
||||
|
|
@ -3639,6 +3645,9 @@ packages:
|
|||
resolution: {integrity: sha512-EULJ8LApcVEPbrfND0cRQqutIOdiIgJ1Mgrhpy755r14xMohPTEpkV/k28SJvuOs9bHRFW8x+KeDAEPiGQPB9Q==}
|
||||
deprecated: This is a stub types definition. parse-path provides its own type definitions, so you do not need this installed.
|
||||
|
||||
'@types/punycode@2.1.4':
|
||||
resolution: {integrity: sha512-trzh6NzBnq8yw5e35f8xe8VTYjqM3NE7bohBtvDVf/dtUer3zYTLK1Ka3DG3p7bdtoaOHZucma6FfVKlQ134pQ==}
|
||||
|
||||
'@types/resolve@1.20.2':
|
||||
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
|
||||
|
||||
|
|
@ -13417,6 +13426,8 @@ snapshots:
|
|||
dependencies:
|
||||
parse-path: 7.1.0
|
||||
|
||||
'@types/punycode@2.1.4': {}
|
||||
|
||||
'@types/resolve@1.20.2': {}
|
||||
|
||||
'@types/trusted-types@2.0.7': {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue