Load additional icons from HTML

When a Web App Manifest is found and loaded, we still want to check HTML
for some additional icons that are usually not added to manifests.
This commit is contained in:
Basti 2018-07-27 17:20:27 +02:00
parent 6cbcbdb54a
commit e503ada44e
2 changed files with 16 additions and 0 deletions

View File

@ -18,6 +18,8 @@ module Manifique
if manifest = fetch_web_manifest
@metadata.load_from_web_manifest(manifest)
parse_apple_touch_icons_from_html
parse_mask_icon_from_html
else
parse_metadata_from_html
end

View File

@ -147,6 +147,20 @@ RSpec.describe Manifique::WebClient do
it "knows which properties were loaded from the web app manifest" do
expect(subject.from_web_manifest.length).to eq(10)
end
it "loads iOS icons from HTML" do
apple_touch_icons = subject.icons.select{|i| i["purpose"] == "apple-touch-icon"}
expect(apple_touch_icons.length).to eq(1)
expect(apple_touch_icons.first["type"]).to eq("image/png")
expect(apple_touch_icons.first["sizes"]).to eq("180x180")
end
it "loads SVG mask icons from HTML" do
mask_icon = subject.icons.find{|i| i["purpose"] == "mask-icon"}
expect(mask_icon["color"]).to eq("#2b90d9")
expect(mask_icon["type"]).to eq("image/svg")
expect(mask_icon["sizes"]).to be_nil
end
end
context "no web app manifest present" do