inline-scripts
inline-scripts copied to clipboard
RegExp is too greedy
The RegExp used to match tags are too greedy. If the source file has, for example, multiple link or script tags on the same line, you'll often get garbage output. As a result, inline-scripts won't run on something built by preact/webpack.
For sure RegExp isn't really the best way to parse HTML, but I was able to make following change (.* to [^>]*), which seems to work around this issue.
const linkTagRegex = /<link (?:[^>]* )?rel="stylesheet"(?:[^>]* )?href="([\w.\-\/]+)"[^>]*>|<link (?:[^>]* )?href="([\w.\-\/]+)"(?:[^>]* )?rel="stylesheet"[^>]*>/;