fix: Fix incorrect image_url parsing from NFT meta (#9956)

* fix: Fix incorrect image_url parsing from NFT meta

* Add regression test
pull/9977/head
nikitosing 7 months ago committed by GitHub
parent 2180db7d60
commit 23419e7180
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex
  2. 21
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/token_controller_test.exs
  3. 5
      cspell.json

@ -54,6 +54,7 @@ defmodule BlockScoutWeb.NFTHelper do
def retrieve_image(image_url) do
image_url
|> URI.decode()
|> URI.encode()
|> compose_ipfs_url()
end

@ -1063,6 +1063,27 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do
"token" => %{"address" => ^token_address, "name" => ^token_name, "type" => ^token_type}
} = json_response(request, 200)
end
# https://github.com/blockscout/blockscout/issues/9906
test "regression for #9906", %{conn: conn} do
token = insert(:token, type: "ERC-721")
instance =
insert(:token_instance,
token_id: 0,
token_contract_address_hash: token.contract_address_hash,
metadata: %{
"image_url" => "ipfs://QmTQBtvkCQKnxbUejwYHrs2G74JR2qFwxPUqRb3BQ6BM3S/gm%20gm%20feelin%20blue%204k.png"
}
)
request = get(conn, "/api/v2/tokens/#{token.contract_address.hash}/instances/0")
assert %{
"image_url" =>
"https://ipfs.io/ipfs/QmTQBtvkCQKnxbUejwYHrs2G74JR2qFwxPUqRb3BQ6BM3S/gm%20gm%20feelin%20blue%204k.png"
} = json_response(request, 200)
end
end
describe "/tokens/{address_hash}/instances/{token_id}/transfers" do

@ -632,7 +632,10 @@
"zksync",
"filecoin",
"Filecoin",
"permissionless"
"permissionless",
"feelin",
"KnxbUejwY",
"Btvk"
],
"enableFiletypes": [
"dotenv",

Loading…
Cancel
Save