Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateSRIHashesModule function generates invalid strings on windows #84

Open
felixcicatt opened this issue Jul 9, 2024 · 1 comment
Labels
bug Something isn't working devex Development Experience good first issue Good for newcomers question Further information is requested windows

Comments

@felixcicatt
Copy link

Because file paths on windows use the backslash character as a path separator, and the generateSRIHashesModule function concatenates the path of pages directly as a string in the perPageSriHashes part of the file it generates, the end result contains invalid strings, because the backslashes need to be escaped:

image

This could be fixed by escaping the paths before concatenating them into the end result, with a function like below. I can submit a PR if you like.

/**
 * @param {string} s 
 * @returns {string}
 */
const escapeJsonString = (s) => {
	if(!s) return s
	const json = JSON.stringify(s)
	return json.substring(1, json.length - 1)
}
@castarco castarco added bug Something isn't working devex Development Experience windows labels Sep 11, 2024
@castarco
Copy link
Contributor

Hi @felixcicatt , please excuse me for taking so much time before answering.

Is this a big problem? Or could be dealt with by relying on WSL? I'm not quite sure about providing this kind of support for Windows, given that almost no single real website runs on it, except for local development environments (and these can be "patched up" via WSL).

@castarco castarco added good first issue Good for newcomers question Further information is requested labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working devex Development Experience good first issue Good for newcomers question Further information is requested windows
Projects
None yet
Development

No branches or pull requests

2 participants