Skip to content

Commit

Permalink
🐛 fix: add redirect messages for declared extensions and URLs
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <[email protected]>
  • Loading branch information
SimonShiki committed Nov 7, 2024
1 parent e6f7cc3 commit af9cc36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@
"eureka.gettingRedux": "Getting Redux...",
"eureka.reduxReady": "Redux is ready.",
"eureka.failedToGetRedux": "Failed to get Redux.",
"eureka.settings.polyfillGlobalInstances": "Expose Scratch internal instances globally"
"eureka.settings.polyfillGlobalInstances": "Expose Scratch internal instances globally",
"eureka.redirectingDeclared": "Redirecting declared extension {extensionURL}",
"eureka.redirectingURL": "Redirecting URL {extensionURL}"
}
8 changes: 8 additions & 0 deletions src/main/patches/applier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
}

if (settings.behavior.redirectDeclared && ctx.declaredIds.includes(extensionURL) && !loadedExtensions.has(extensionURL)) {
log.info(formatMessage({
id: 'eureka.redirectingDeclared',
default: 'Redirecting declared extension {extensionURL}'
}, { extensionURL }));
return forwardedLoadExtensionURL(extensionURL);
}

Expand All @@ -178,6 +182,10 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {

if (settings.behavior.redirectURL && isURL(extensionURL) && !loadedExtensions.has(extensionURL)) {
ctx.declaredIds.push(extensionURL);
log.info(formatMessage({
id: 'eureka.redirectingURL',
default: 'Redirecting URL {extensionURL}'
}, { extensionURL }));
return forwardedLoadExtensionURL(extensionURL);
}

Expand Down

0 comments on commit af9cc36

Please sign in to comment.