feature: Add integrity & crossOrigin options to useScript#717
Open
DanielBoa wants to merge 3 commits intojuliencrn:masterfrom
Open
feature: Add integrity & crossOrigin options to useScript#717DanielBoa wants to merge 3 commits intojuliencrn:masterfrom
integrity & crossOrigin options to useScript#717DanielBoa wants to merge 3 commits intojuliencrn:masterfrom
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add new options to allow the integrity of a script loaded via
useScriptto be validated using Subresource Integrity (SRI).Two new properties:
integrity- allows a sha to be set for the external resource (further reading)crossOrigin- allows the setting of thecrossoriginattribute, if omitted andintegrityis set this is automatically set toanonymous(further reading)Why
I encountered this hook and wanted to use it but had the lack of this feature prevented me from doing so in the context.
Demo
https://codesandbox.io/p/sandbox/rdnw2y
Misc
srcof each test case as the tests were colliding. This is because theuseScripthook has a module scoped cache keyed bysrceslint-plugin-importto get the linting to work at all, I've avoided including that as I wasn't sure why this was the case. Also the linter seemed to flag several issues in other hooks which I ignored