ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

web: Resolve URLs without a protocol in the extension player and improve error messages

Open Korne127 opened this issue 1 year ago • 6 comments

Currently, only URLs explicitly including the web protocol (HTTPS or HTTP) in the beginning can be resolved in the extension player. Additionally, if the URL doesn't include the HTTPS or HTTP protocol in the beginning, a wrong error is displayed. It states that the user ran Ruffle on the file: protocol which is wrong and confusing: Bildschirmfoto 2024-06-28 um 15 53 04

This pull request fixes this. With this pull request, the extension player resolves URLs without a protocol. It adds https:// or http:// if the URL is likely a valid web URL and file:/// if the URL is a valid file URL. To determine whether HTTPS or HTTP should be used, Ruffle tests whether the server supports HTTPS. HTTP is only used if the server only supports HTTP and not HTTPS. This test happens while the loading screen is displayed.

This means that the user can now enter URLs without a leading https:// like you (usually) do in the browser.

Additionally, this pull request fixes and improves the error behaviour if the URL can't be resolved or used. Instead of the wrong error, one of four more specific errors will be displayed:

  • One new error if the given URL is a local file URL: Bildschirmfoto 2024-06-28 um 15 56 26
  • One new error if the given URL uses a different protocol than https, http or file (e.g. ftp): Bildschirmfoto 2024-06-28 um 15 57 44
  • One new error if the given URL can't be resolved to any valid URL for any protocol Bildschirmfoto 2024-06-28 um 15 58 07
  • And the usual SWF file not found error if the file under the given web URL couldn't be found. That error has also been modified to also include the tip that the HTTP protocol should be (explicitly) used for websites that don't support HTTPS: Bildschirmfoto 2024-06-28 um 15 54 12

Also, a bug that caused the document title to not be set correctly if the SWF URL was the main page of a domain has been fixed. The handling of setting the document title of the extension player has generally been made more consistent.

Korne127 avatar Jun 28 '24 14:06 Korne127

hello Korne, useful PR! :) sorry but there is a typo on the 4th image!

Croworbit avatar Jun 28 '24 14:06 Croworbit

Hey :) Thanks for the nice response and the feedback :D I'm sorry, but I genuinely don't see the typo… can you point it out for me? 😅

Korne127 avatar Jun 28 '24 14:06 Korne127

Hey :) Thanks for the nice response and the feedback :D I'm sorry, but I genuinely don't see the typo… can you point it out for me? 😅

"The url blabla test is no valid url" I expected "the url blablatest is not a valid url"

Croworbit avatar Jun 28 '24 14:06 Croworbit

Hmm, I would have thought that both is valid tbh, although the second one is probably better. I can change it, but when I went back to look at the messages, I don't really like the repetition. I think I might change it to "Bla-Bla-Test is not a valid URL". (And change enter to include on the last screenshot.)

Korne127 avatar Jun 28 '24 15:06 Korne127

amittedly its a nitpick 😅

Croworbit avatar Jun 28 '24 16:06 Croworbit

@Croworbit Don't worry, I really appreciate it! Especially the things that I overlooked myself are good to know :)

Korne127 avatar Jun 29 '24 12:06 Korne127

I rebased the Pull Request and adapted it accordingly to @kjarosh's suggestions.

Korne127 avatar Jul 26 '24 14:07 Korne127

Extension-player specific error messages (as well as the http advice) are now only shown in the extension player, and a new additional error message is displayed if a website is misconfigured and uses a different protocol.

This is done by creating a so-called OriginAPI which allows the web core to access behaviour that's specific to the Ruffle origin (selfhosted, demo or extension). For more information, see the last commit message.

Korne127 avatar Aug 09 '24 15:08 Korne127