sources: add image_url?, page_url?, and profile_url? methods.

Add methods to Source::URL for determining whether a URL is an image
URL, a page URL, or a profile URL.

Also add more source URL tests and fix various URL parsing bugs.
This commit is contained in:
evazion
2022-05-01 17:55:58 -05:00
parent d54ad9103b
commit 23b8350320
47 changed files with 571 additions and 165 deletions

View File

@@ -125,5 +125,20 @@ module Sources
EOS
end
should "parse Foundation URLs correctly" do
assert(Source::URL.image_url?("https://f8n-ipfs-production.imgix.net/QmX4MotNAAj9Rcyew43KdgGDxU1QtXemMHoUTNacMLLSjQ/nft.png"))
assert(Source::URL.image_url?("https://f8n-production-collection-assets.imgix.net/0x3B3ee1931Dc30C1957379FAc9aba94D1C48a5405/128711/QmcBfbeCMSxqYB3L1owPAxFencFx3jLzCPFx6xUBxgSCkH/nft.png"))
assert(Source::URL.image_url?("https://f8n-production-collection-assets.imgix.net/0xFb0a8e1bB97fD7231Cd73c489dA4732Ae87995F0/4/nft.png"))
assert(Source::URL.image_url?("https://assets.foundation.app/0x21Afa9aB02B6Fb7cb483ff3667c39eCdd6D9Ea73/4/nft.mp4"))
assert(Source::URL.image_url?("https://assets.foundation.app/7i/gs/QmU8bbsjaVQpEKMDWbSZdDD6GsPmRYBhQtYRn8bEGv7igs/nft_q4.mp4"))
assert(Source::URL.image_url?("https://d2ybmb80bbm9ts.cloudfront.net/zd/BD/QmXiCEoBLcpfvpEwAEanLXe3Tjr5ykYJFzCVfpzDDQzdBD/nft_q4.mp4"))
assert(Source::URL.page_url?("https://foundation.app/@asuka111art/dinner-with-cats-82426"))
assert(Source::URL.page_url?("https://foundation.app/@mochiiimo/~/97376"))
assert(Source::URL.profile_url?("https://foundation.app/@mochiiimo"))
assert(Source::URL.profile_url?("https://foundation.app/0x7E2ef75C0C09b2fc6BCd1C68B6D409720CcD58d2"))
end
end
end