MCPcopy
hub / github.com/vitejs/vite / parseSrcset

Function parseSrcset

packages/vite/src/node/utils.ts:784–796  ·  view source on GitHub ↗
(string: string)

Source from the content-addressed store, hash-verified

782const escapedSpaceCharacters = /(?: |\\t|\\n|\\f|\\r)+/g
783
784export function parseSrcset(string: string): ImageCandidate[] {
785 const matches = string
786 .trim()
787 .replace(escapedSpaceCharacters, ' ')
788 .replace(/\r?\n/, '')
789 .replace(/,\s+/, ', ')
790 .replaceAll(/\s+/g, ' ')
791 .matchAll(imageCandidateRegex)
792 return Array.from(matches, ({ groups }) => ({
793 url: groups?.url?.trim() ?? '',
794 descriptor: groups?.descriptor?.trim() ?? '',
795 })).filter(({ url }) => !!url)
796}
797
798export function processSrcSet(
799 srcs: string,

Callers 2

processSrcSetFunction · 0.85
processSrcSetSyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected