MCPcopy
hub / github.com/vercel/next.js / getMetadataLinks

Function getMetadataLinks

test/e2e/app-dir/metadata-static-file/utils.ts:4–34  ·  view source on GitHub ↗
(browser: Playwright)

Source from the content-addressed store, hash-verified

2import type { Playwright } from '../../../lib/next-webdriver'
3
4async function getMetadataLinks(browser: Playwright) {
5 const links = await browser.locator('link').evaluateAll((elements: any[]) => {
6 return elements
7 .filter((el) => {
8 if (el.href.includes('/_next/static')) {
9 return false
10 }
11
12 return [
13 '/favicon.ico',
14 '/manifest.json',
15 '/manifest.webmanifest',
16 // Below may have suffixes like /icon1.png, /icon2.png, etc.
17 // Or has suffixes like /icon-xxxxxx.png, /icon-image-yyyyyy.jpg, etc.
18 '/icon',
19 '/apple-icon',
20 '/opengraph-image',
21 '/twitter-image',
22 ].some((file) =>
23 new URL(el.href, window.location.origin).pathname.includes(file)
24 )
25 })
26 .map((el) => ({
27 href: new URL(el.href, window.location.origin).pathname,
28 rel: el.rel,
29 ...(el.type && { type: el.type }),
30 }))
31 .sort((a, b) => a.href.localeCompare(b.href))
32 })
33 return links
34}
35
36async function getMetadataMetas(browser: Playwright) {
37 const metas = await browser.locator('meta').evaluateAll((elements: any[]) => {

Callers 1

Calls 6

locatorMethod · 0.80
includesMethod · 0.80
someMethod · 0.80
sortMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected