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:
@@ -68,5 +68,18 @@ module Sources
|
||||
context "A non-existing or deleted post" do
|
||||
strategy_should_work("https://booth.pm/en/items/2003079", deleted: true)
|
||||
end
|
||||
|
||||
should "Parse Booth URLs correctly" do
|
||||
assert(Source::URL.image_url?("https://booth.pximg.net/8bb9e4e3-d171-4027-88df-84480480f79d/i/2864768/00cdfef0-e8d5-454b-8554-4885a7e4827d_base_resized.jpg"))
|
||||
assert(Source::URL.image_url?("https://s2.booth.pm/b242a7bd-0747-48c4-891d-9e8552edd5d7/i/3746752/52dbee27-7ad2-4048-9c1d-827eee36625c_base_resized.jpg"))
|
||||
assert(Source::URL.image_url?("https://s.booth.pm/1c9bc77f-8ac1-4fa4-94e5-839772ab72cb/i/750997/774dc881-ce6e-45c6-871b-f6c3ca6914d5.png"))
|
||||
assert(Source::URL.image_url?("https://booth.pximg.net/users/3193929/icon_image/5be9eff4-1d9e-4a79-b097-33c1cd4ad314.png"))
|
||||
assert(Source::URL.image_url?("https://s2.booth.pm/8bb9e4e3-d171-4027-88df-84480480f79d/3d70de06-8e7c-444e-b8eb-a8a95bf20638.png"))
|
||||
assert(Source::URL.page_url?("https://booth.pm/en/items/2864768"))
|
||||
assert(Source::URL.page_url?("https://re-face.booth.pm/items/3435711"))
|
||||
assert(Source::URL.profile_url?("https://re-face.booth.pm"))
|
||||
refute(Source::URL.profile_url?("https://www.booth.pm"))
|
||||
refute(Source::URL.profile_url?("https://booth.pm"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user