rehype-og-card 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -128,7 +128,7 @@ Expiration is calculated using the cached timestamp stored in the cache itself.
128
128
  User agent to use for fetching the OG metadata and images.
129
129
 
130
130
  - Type: `string`
131
- - Default: `"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"`
131
+ - Default: `"Mozilla/5.0 (compatible; rehype-og-card/2.0; +https://github.com/Robot-Inventor/rehype-og-card/; purpose=link-preview; twitterbot-compatible)"`
132
132
 
133
133
  ### `decoding`
134
134
 
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ const DEFAULT_OPTIONS = {
13
13
  buildCache: false,
14
14
  buildCacheMaxAge: DEFAULT_CACHE_MAX_AGE_MS,
15
15
  buildCachePath: "./node_modules/.cache",
16
- crawlerUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
16
+ crawlerUserAgent: "Mozilla/5.0 (compatible; rehype-og-card/2.0; +https://github.com/Robot-Inventor/rehype-og-card/; purpose=link-preview; twitterbot-compatible)",
17
17
  decoding: "async",
18
18
  enableSameTextURLConversion: false,
19
19
  excludeDomains: [],
package/dist/types.d.ts CHANGED
@@ -69,7 +69,7 @@ interface RehypeOGCardOptions {
69
69
  buildCacheMaxAge?: number | false;
70
70
  /**
71
71
  * User agent to use for fetching the OG metadata and images.
72
- * @default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
72
+ * @default "Mozilla/5.0 (compatible; rehype-og-card/2.0; +https://github.com/Robot-Inventor/rehype-og-card/; purpose=link-preview; twitterbot-compatible)"
73
73
  */
74
74
  crawlerUserAgent?: string;
75
75
  }
@@ -46,10 +46,8 @@ const getOGData = async (url, userAgent) => {
46
46
  });
47
47
  const OGImage = result.ogImage ? result.ogImage[0] : null;
48
48
  const OGImageURL = resolveAbsoluteURL(OGImage?.url, url);
49
- const faviconURL = result.favicon
50
- ? `https://www.google.com/s2/favicons?domain=${new URL(url).hostname}`
51
- : // eslint-disable-next-line no-undefined
52
- undefined;
49
+ const resolvedFaviconURL = result.favicon ? resolveAbsoluteURL(result.favicon, url) : null;
50
+ const faviconURL = resolvedFaviconURL ?? `https://www.google.com/s2/favicons?domain=${new URL(url).hostname}`;
53
51
  return {
54
52
  OGImageAlt: OGImage?.alt,
55
53
  OGImageHeight: OGImage?.height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rehype-og-card",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Rehype plugin to convert text links to link cards",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",