Intercept `webbrowser` open requests for local html files as well as localhost
Addresses #4118
Hooks into the new 'show-html-file' comm path to display html files opened with the webbrowser python module in the viewer pane.
Previously we overrode the webbrowser opening to forward localhost servers, so this just adds a condition to check for html files and do a similar thing.
Here's an example of it working on a bokeh plot that previously used to open in an external browser:
Rough edges:
- Bokeh widget doesn't seem to care about the size of the viewer pane.
- Not sure if how I am checking for the request being an html file is robust enough. I dont think there's an equivalent URI class in python that we can use, right?
QA Notes
Not sure if how I am checking for the request being an html file is robust enough. I dont think there's an equivalent URI class in python that we can use, right?
You could use urlparse from Python's urllib, which returns a named tuple, and check for the file schema and that path ends with .htm/html, but it does not do any sort of validation, if that is what you consider to be robustness.
@seeM , 1 + 2 (done) 3. Not sure, I think it will depend on what we decide about how we differentiate between the two.
@isabelizimm , thanks! Used urlparse in https://github.com/posit-dev/positron/pull/4178/commits/f7a00118f0791d74f5b6540b9b713639cec99a6f