Skip to content

Commit 71754a9

Browse files
committed
web: Don't try to connect to an unsupported URL
If Ruffle recognises that a URL is invalid or not supported, it now doesn't try to connect to it, but instantly panics. This reduces unnecessary connection attempts and improves reaction speed.
1 parent acedc88 commit 71754a9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

web/packages/core/src/ruffle-player.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,11 @@ export class RufflePlayer extends HTMLElement {
20552055
this.container.prepend(div);
20562056
}
20572057

2058+
public displayRootMovieUnsupportedUrlMessage(unsupportedUrl: string) {
2059+
this.swfUrl = new URL(unsupportedUrl, document.baseURI);
2060+
this.displayRootMovieDownloadFailedMessage(false);
2061+
}
2062+
20582063
protected displayRootMovieDownloadFailedMessage(invalidSwf: boolean): void {
20592064
const openInNewTab = this.loadedConfig?.openInNewTab;
20602065
if (

web/packages/extension/src/player.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ async function load(options: string | DataLoadOptions | URLLoadOptions) {
123123
}
124124

125125
const supportedURL = utils.supportedURL(url);
126+
if (!supportedURL && urlString) {
127+
player.displayRootMovieUnsupportedUrlMessage(urlString);
128+
return;
129+
}
126130
if (supportedURL && !(await utils.hasHostPermissionForSpecifiedTab(origin!))) {
127131
const result = await showModal(origin!);
128132
if (result === "") {

0 commit comments

Comments
 (0)