diff --git a/components/nft/collection/ChangeMediaModal.vue b/components/nft/collection/ChangeMediaModal.vue index 96ab3e3..6c6af49 100644 --- a/components/nft/collection/ChangeMediaModal.vue +++ b/components/nft/collection/ChangeMediaModal.vue @@ -147,7 +147,7 @@ export default { url = url.trim(); } - if (!url.startsWith("http") && !url.startsWith("ipfs")) { + if (!url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("ipfs://") && !url.startsWith("ar://")) { if (!url.includes("/") && !url.includes(".")) { return "ipfs://" + url; } else if (url.split(".").length > 2) { diff --git a/utils/ipfsUtils.js b/utils/ipfsUtils.js index 0c21eba..e00801d 100644 --- a/utils/ipfsUtils.js +++ b/utils/ipfsUtils.js @@ -41,6 +41,7 @@ export function getIpfsUrl(url) { } export async function getWorkingUrl(url) { + const config = useRuntimeConfig(); let ipfsUrl = url if (url.startsWith("http")) { @@ -87,7 +88,7 @@ export async function getWorkingUrl(url) { } } } else if (url.startsWith("ar://")) { - const arweaveUrl = url.replace("ar://", this.$config.arweaveGateway) + const arweaveUrl = url.replace("ar://", config.arweaveGateway) try { const response = await axios.head(arweaveUrl, { signal: AbortSignal.timeout(abortTimeout) }) diff --git a/utils/textUtils.js b/utils/textUtils.js index 9812000..f80f832 100644 --- a/utils/textUtils.js +++ b/utils/textUtils.js @@ -73,6 +73,8 @@ export function findFirstUrl(text) { } export function getAllImagesFromText(text) { + const config = useRuntimeConfig(); + if (!text) { return [] } @@ -100,7 +102,7 @@ export function getAllImagesFromText(text) { } else { for (let i = 0; i < imageLinks.length; i++) { if (imageLinks[i].startsWith('ar://')) { - imageLinks[i] = imageLinks[i].replace('ar://', this.$config.arweaveGateway) + imageLinks[i] = imageLinks[i].replace('ar://', config.arweaveGateway) } else if (imageLinks[i].startsWith('ipfs://')) { imageLinks[i] = imageLinks[i].replace('ipfs://', 'https://ipfs.io/ipfs/') } @@ -111,6 +113,8 @@ export function getAllImagesFromText(text) { } export function getImageFromText(text) { + const config = useRuntimeConfig(); + if (!text) { return null } @@ -137,7 +141,7 @@ export function getImageFromText(text) { } else { for (let i = 0; i < imageLinks.length; i++) { if (imageLinks[i].startsWith('ar://')) { - imageLinks[i] = imageLinks[i].replace('ar://', this.$config.arweaveGateway) + imageLinks[i] = imageLinks[i].replace('ar://', config.arweaveGateway) } else if (imageLinks[i].startsWith('ipfs://')) { imageLinks[i] = imageLinks[i].replace('ipfs://', 'https://ipfs.io/ipfs/') } @@ -403,6 +407,7 @@ export function hasTextBlankCharacters(text) { } export function imgParsing(text) { + const config = useRuntimeConfig(); const imageRegex = /(?:https?:\/\/|ipfs:\/\/|ar:\/\/)(?:[^\/\s]+\/)+[^\s]+\.(?:jpe?g|gif|webp|png|img)/gi if (!imageRegex.test(text)) { @@ -412,7 +417,7 @@ export function imgParsing(text) { return text.replace(imageRegex, function (url) { let newUrl = url if (url.startsWith('ar://')) { - newUrl = url.replace('ar://', this.$config.arweaveGateway) + newUrl = url.replace('ar://', config.arweaveGateway) } else if (url.startsWith('ipfs://')) { newUrl = url.replace('ipfs://', 'https://ipfs.io/ipfs/') } @@ -422,6 +427,8 @@ export function imgParsing(text) { } export function imgWithoutExtensionParsing(text) { + const config = useRuntimeConfig(); + // if image doesn't have an extension, it won't be parsed by imgParsing // so we need to parse it here // but image link needs to end with "?.img" to be parsed (otherwise frontend will think it's a link) @@ -437,7 +444,7 @@ export function imgWithoutExtensionParsing(text) { return text.replace(imageRegex, function (url) { if (url.startsWith('ar://')) { - url = url.replace('ar://', this.$config.arweaveGateway) + url = url.replace('ar://', config.arweaveGateway) } else if (url.startsWith('ipfs://')) { url = url.replace('ipfs://', 'https://ipfs.io/ipfs/') }