Skip to content

generateSRIHashesModule function generates invalid strings on windows #84

Open
@felixcicatt

Description

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)
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdevexDevelopment Experiencegood first issueGood for newcomersquestionFurther information is requestedwindows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions