mozilla / page-metadata-parser

DEPRECATED - A Javascript library for parsing metadata on a web page.
https://www.npmjs.com/package/page-metadata-parser
Mozilla Public License 2.0
270 stars 42 forks source link

defaultValue for favicon should be "/favicon.ico" rather than "favicon.ico" #120

Closed darinwf closed 2 years ago

darinwf commented 3 years ago

According to the HTML spec (https://html.spec.whatwg.org/#rel-icon), the fallback favicon should be "/favicon.ico" resolved against the document URL.

However, parser.js falls back to resolving "favicon.ico" against the document URL, which can result in some favicon URLs that are unexpected.

The fix is pretty trivial:

--- parser.js   2021-08-30 13:01:51.000000000 -0700
+++ parser.js-new   2021-08-30 16:02:05.000000000 -0700
@@ -94,7 +94,7 @@
         }
       }
     ],
-    defaultValue: (context) => 'favicon.ico',
+    defaultValue: (context) => '/favicon.ico',
     processors: [
       (icon_url, context) => makeUrlAbsolute(context.url, icon_url)
     ]