Skip to content

Commit

Permalink
🎨 Copy iscnId without version
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Dec 15, 2023
1 parent f013264 commit 47604ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pages/view/_iscnId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ import { getIPFSUrlFromISCN } from '~/utils/cosmos/iscn'
import { ISCNRecordWithID } from '~/utils/cosmos/iscn/iscn.type'
import { downloadJSON } from '~/utils/misc'
import { logTrackerEvent } from '~/utils/logger'
import { ellipsis, copyToClipboard } from '~/utils/ui'
import { ellipsis, copyToClipboard,extractIscnIdPrefix } from '~/utils/ui'
import {
ISCN_PREFIX,
BIG_DIPPER_TX_BASE_URL,
Expand Down Expand Up @@ -914,8 +914,9 @@ export default class ViewIscnIdPage extends Vue {
}
handleCopyIscnId() {
logTrackerEvent(this, 'ISCNView', 'CopyISCNID', this.iscnId, 1);
copyToClipboard(this.iscnId)
logTrackerEvent(this, 'ISCNView', 'CopyISCNID', this.iscnId, 1)
const iscnIdPrefix = extractIscnIdPrefix(this.iscnId)
copyToClipboard(iscnIdPrefix)
this.isOpenCopiedAlert = true
}
}
Expand Down
9 changes: 9 additions & 0 deletions utils/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ export function copyToClipboard(text){
selection.removeAllRanges();
document.body.removeChild(copyText);
}

export function extractIscnIdPrefix(iscnId) {
const regex = /^(iscn:\/\/likecoin-chain\/[^/]+)/;
const match = iscnId.match(regex);
if (match && match[1]) {
return match[1];
}
return null;
}

0 comments on commit 47604ed

Please sign in to comment.