Skip to content

Commit

Permalink
split commas followed by non-whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
caseycarroll committed Mar 4, 2024
1 parent f649570 commit bca6dad
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,29 +769,8 @@ export function processSrcSetSync(
)
}

const cleanSrcSetRE =
/(?:url|image|gradient|cross-fade)\([^)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|data:\w+\/[\w.+\-]+;base64,[\w+/=]+|[^\s?]*\?\S*,\S*/g
function splitSrcSet(srcs: string) {
const parts: string[] = []
/**
* There could be a ',' inside of:
* - url(data:...)
* - linear-gradient(...)
* - "data:..."
* - data:...
* - query parameter ?...
*/
const cleanedSrcs = srcs.replace(cleanSrcSetRE, blankReplacer)
let startIndex = 0
let splitIndex: number
do {
splitIndex = cleanedSrcs.indexOf(',', startIndex)
parts.push(
srcs.slice(startIndex, splitIndex !== -1 ? splitIndex : undefined),
)
startIndex = splitIndex + 1
} while (splitIndex !== -1)
return parts
return srcs.split(/,\s+/)
}

const windowsDriveRE = /^[A-Z]:/
Expand Down

0 comments on commit bca6dad

Please sign in to comment.