forked from ScratchAddons/ScratchAddons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement idea suggested in ScratchAddons#6665
- Loading branch information
Showing
3 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
|
||
export const BACKPACK_URL = "https://backpack.scratch.mit.edu/"; | ||
|
||
// Inserting sprites from the backpack requests a ZIP archive from backpack.scratch.mit.edu, so we want to allow those | ||
export const SPRITE_FILE_EXTENSION = ".zip"; | ||
|
||
|
||
/** | ||
* Returns true if a web worker request is being caused by the Scratch bug | ||
* https://github.com/scratchfoundation/scratch-gui/issues/8805. | ||
* @param {*} message The message being sent to the web worker. | ||
* @returns {boolean} | ||
*/ | ||
export function isBadRequest(message) { | ||
if (!message) return false; | ||
|
||
if (typeof message.id !== "string" || typeof message.url !== "string") return false; | ||
|
||
if (!message.url.startsWith(BACKPACK_URL)) return false; | ||
|
||
if (message.url.endsWith(SPRITE_FILE_EXTENSION)) return false; | ||
|
||
return true; | ||
} |
This file contains 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
This file contains 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