From e503ada44eddb55ee2e134fc0249c339a2611cb1 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 27 Jul 2018 17:20:27 +0200 Subject: [PATCH] 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. --- lib/manifique/web_client.rb | 2 ++ spec/manifique/web_client_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/manifique/web_client.rb b/lib/manifique/web_client.rb index 235c040..6702de1 100644 --- a/lib/manifique/web_client.rb +++ b/lib/manifique/web_client.rb @@ -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 diff --git a/spec/manifique/web_client_spec.rb b/spec/manifique/web_client_spec.rb index 58cf9de..5b903c1 100644 --- a/spec/manifique/web_client_spec.rb +++ b/spec/manifique/web_client_spec.rb @@ -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