Skip to content

Commit

Permalink
fix(client): prevent add route into the main page browser history (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Mar 11, 2022
1 parent 8f27c12 commit 1e5230a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sandpack-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@ export class SandpackClient {
);
}

this.iframe.src = options.startRoute
const urlSource = options.startRoute
? new URL(options.startRoute, this.bundlerURL).toString()
: this.bundlerURL;

this.iframe.contentWindow?.location.replace(urlSource);

this.iframeProtocol = new IFrameProtocol(this.iframe, this.bundlerURL);

this.unsubscribeGlobalListener = this.iframeProtocol.globalListen(
Expand Down
2 changes: 1 addition & 1 deletion sandpack-react/src/contexts/sandpackContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class SandpackProvider extends React.PureComponent<
const client = this.clients[clientId];
if (client) {
client.cleanup();
client.iframe.removeAttribute("src");
client.iframe.contentWindow?.location.replace("about:blank");
delete this.clients[clientId];
} else {
delete this.preregisteredIframes[clientId];
Expand Down

0 comments on commit 1e5230a

Please sign in to comment.