Skip to content

Commit 29de4e1

Browse files
committed
URL in coin description to link
1 parent c55caaa commit 29de4e1

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

frontend/src/components/CoinView.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {arrayBufferToBase64} from "@/utils/bytes2img.js"
55
import {appTitle} from "@/composables/appTitle.js"
66
import i18n from '../i18n'
77
import StatusItem from "./StatusItem.vue"
8-
import {convertFraction, formatYear} from "@/utils/formatter.js";
8+
import {convertFraction, convertLinksToAnchors, formatYear} from "@/utils/formatter.js";
99
import {useService} from "@/composables/useService.js";
1010
import InfoRow from "@/components/InfoRow.vue";
1111
@@ -171,8 +171,8 @@ onUnmounted(async () => {
171171
</v-container>
172172

173173
<v-container>
174-
<p>{{ coinData[service.infoFieldIndex('features')] }}</p>
175-
<p>{{ coinData[service.infoFieldIndex('subject')] }}</p>
174+
<p v-html="convertLinksToAnchors(coinData[service.infoFieldIndex('features')])"></p>
175+
<p v-html="convertLinksToAnchors(coinData[service.infoFieldIndex('subject')])"></p>
176176
</v-container>
177177
</template>
178178

frontend/src/utils/formatter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,13 @@ export function formatYear(enable_bc, year) {
6060

6161
return year;
6262
}
63+
64+
export function convertLinksToAnchors(text) {
65+
const urlRegex = /(https?:\/\/[^\s]+)/g;
66+
try {
67+
return text.replace(urlRegex, '<a href="$1" target="_blank">$1</a>');
68+
}
69+
catch (e) {
70+
return text;
71+
}
72+
}

0 commit comments

Comments
 (0)