diff --git a/packages/desktop/views/dashboard/collectibles/Collectibles.svelte b/packages/desktop/views/dashboard/collectibles/Collectibles.svelte
index 686a058eaf..4757a004d9 100644
--- a/packages/desktop/views/dashboard/collectibles/Collectibles.svelte
+++ b/packages/desktop/views/dashboard/collectibles/Collectibles.svelte
@@ -1,6 +1,6 @@
@@ -8,6 +8,6 @@
{/if}
{#if $collectiblesRoute === CollectiblesRoute.Details}
-
+
{/if}
diff --git a/packages/desktop/views/dashboard/collectibles/views/DetailsView.svelte b/packages/desktop/views/dashboard/collectibles/views/NftDetailsView.svelte
similarity index 100%
rename from packages/desktop/views/dashboard/collectibles/views/DetailsView.svelte
rename to packages/desktop/views/dashboard/collectibles/views/NftDetailsView.svelte
diff --git a/packages/desktop/views/dashboard/collectibles/views/index.js b/packages/desktop/views/dashboard/collectibles/views/index.js
index 47a14f11c7..42dc5fb780 100644
--- a/packages/desktop/views/dashboard/collectibles/views/index.js
+++ b/packages/desktop/views/dashboard/collectibles/views/index.js
@@ -1,2 +1,2 @@
-export { default as DetailsView } from './DetailsView.svelte'
+export { default as NftDetailsView } from './NftDetailsView.svelte'
export { default as GalleryView } from './GalleryView.svelte'
diff --git a/packages/shared/components/modals/CollectibleDetailsMenu.svelte b/packages/shared/components/modals/CollectibleDetailsMenu.svelte
index 6a1987fc4b..57af591013 100644
--- a/packages/shared/components/modals/CollectibleDetailsMenu.svelte
+++ b/packages/shared/components/modals/CollectibleDetailsMenu.svelte
@@ -4,12 +4,15 @@
import { closePopup, openPopup } from '@auxiliary/popup/actions'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { burnNft } from '@core/wallet'
- import { INft } from '@core/nfts'
+ import { INft, rewriteIpfsUri } from '@core/nfts'
import { CollectiblesRoute, collectiblesRouter } from '@core/router'
+ import { openUrlInBrowser } from '@core/app'
export let modal: Modal = undefined
export let nft: INft
+ $: url = composeUrl(nft?.parsedMetadata?.uri)
+
function openBurnNft(): void {
openPopup({
type: 'confirmation',
@@ -36,13 +39,40 @@
},
})
}
+
+ function composeUrl(targetUrl: string): string {
+ if (!targetUrl) {
+ return undefined
+ }
+ const url = new URL(targetUrl)
+
+ switch (url.protocol) {
+ case 'http:':
+ return targetUrl.replace('http:', 'https:')
+ case 'https:':
+ return targetUrl
+ case 'ipfs:':
+ return rewriteIpfsUri(targetUrl)
+ default:
+ return undefined
+ }
+ }
+
+ function handleOpenMediaClick(): void {
+ openUrlInBrowser(url)
+ }
-
-
-
+
+
+
diff --git a/packages/shared/lib/core/app/utils/openUrlInBrowser.ts b/packages/shared/lib/core/app/utils/openUrlInBrowser.ts
index 6da5bc5956..894ff7f19d 100644
--- a/packages/shared/lib/core/app/utils/openUrlInBrowser.ts
+++ b/packages/shared/lib/core/app/utils/openUrlInBrowser.ts
@@ -2,6 +2,7 @@ import { closePopup, openPopup } from '@auxiliary/popup'
import { localize } from '@core/i18n'
import { Platform } from '../classes/platform.class'
import { externalAllowedLinks } from '../constants'
+import { showAppNotification } from '@auxiliary/notification'
export function openUrlInBrowser(targetUrl: string): void {
const url = new URL(targetUrl)
@@ -9,7 +10,13 @@ export function openUrlInBrowser(targetUrl: string): void {
const isAllowed = externalAllowedLinks.includes(domain) || externalAllowedLinks.includes(domain + url.pathname)
- if (isAllowed) {
+ if (url.protocol !== 'https:') {
+ showAppNotification({
+ alert: true,
+ type: 'error',
+ message: localize('popups.externalUrl.invalidProtocol'),
+ })
+ } else if (isAllowed) {
Platform.openUrl(targetUrl)
} else {
openPopup({
diff --git a/packages/shared/lib/core/nfts/utils/index.ts b/packages/shared/lib/core/nfts/utils/index.ts
index 7154e46885..a809bb6e80 100644
--- a/packages/shared/lib/core/nfts/utils/index.ts
+++ b/packages/shared/lib/core/nfts/utils/index.ts
@@ -1,3 +1,4 @@
export * from './buildNftFromNftOutput'
export * from './getIsSpendableFromUnspentNftOutput'
export * from './parseNftMetadata'
+export * from './rewriteIpfsUri'
diff --git a/packages/shared/lib/core/nfts/utils/rewriteIpfsUri.ts b/packages/shared/lib/core/nfts/utils/rewriteIpfsUri.ts
new file mode 100644
index 0000000000..57c5b0ab83
--- /dev/null
+++ b/packages/shared/lib/core/nfts/utils/rewriteIpfsUri.ts
@@ -0,0 +1,5 @@
+export function rewriteIpfsUri(ipfsUri: string): string {
+ const url = new URL(ipfsUri)
+
+ return 'https://ipfs.io/ipfs/' + url.pathname.replace('//', '')
+}
diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json
index 59b5ed2063..df55ff58b2 100644
--- a/packages/shared/locales/en.json
+++ b/packages/shared/locales/en.json
@@ -563,7 +563,7 @@
"menu": {
"download": "Download",
"setAvatar": "Set NFT as profile avatar",
- "view": "View in IPFS",
+ "view": "View media in browser",
"burn": "Burn NFT"
}
},
@@ -704,7 +704,8 @@
"title": "Open URL in Browser",
"body": "Are you sure you want to open \"{url}\" in the browser?",
"hint": "This URL is unknown to Firefly. Please double check the URL before opening it.",
- "action": "Open URL"
+ "action": "Open URL",
+ "invalidProtocol": "Cannot open URL with invalid protocol"
},
"hideAccount": {
"title": "Hide {name}?",