Attach allowed origins changed also to hook in useSaveStateHook#1415
Merged
abcampo-iry merged 1 commit intomainfrom Apr 1, 2026
Merged
Attach allowed origins changed also to hook in useSaveStateHook#1415abcampo-iry merged 1 commit intomainfrom
abcampo-iry merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the useScratchSaveState hook to use the getScratchAllowedOrigin() utility function instead of directly using process.env.ASSETS_URL, aligning with the fix introduced in PR #1413. This ensures proper origin validation for postMessage communication with the Scratch iframe when ASSETS_URL includes a path component.
Changes:
- Updated
useScratchSaveState.jsto import and usegetScratchAllowedOrigin()for origin validation instead of inline origin logic - Updated
useScratchSaveState.test.jsto properly mockgetScratchAllowedOriginand added test coverage for the edge case where ASSETS_URL contains a path - The hook now correctly normalizes asset URLs to their origin for postMessage validation, matching the implementation pattern used in
ScratchContainer.jsxand other scratch-related utilities
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/hooks/useScratchSaveState.js | Updated to call getScratchAllowedOrigin() for origin validation instead of directly using process.env.ASSETS_URL |
| src/hooks/useScratchSaveState.test.js | Added import and mock for getScratchAllowedOrigin, updated test setup, and added new test case for ASSETS_URL with path component |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…-url-for-environments
778effb to
e2f60c5
Compare
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.
Following: #1413
Closes: https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1274