Add support for loading http(s) URLs#1
Merged
Merged
Conversation
The positional argument now accepts an http:// or https:// URL in addition to a file path. URLs are detected case-insensitively and loaded directly via the webview; anything else is still treated as a file. Piped stdin continues to take precedence over both. Updates help text, usage message, and README accordingly.
Prepares for release of the http(s) URL input feature.
Expose window.webview.version to the page and set a webview-cli/<version> User-Agent so remote pages can detect they're rendered inside webview (in JS, or server-side before any JS runs). wry replaces the UA wholesale, so this token becomes the full User-Agent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Just wanted to add URL support.
AI Summary
Adds the ability to render a remote page by passing an
http://orhttps://URL as the positional argument, alongside the existing file-path and piped-stdin inputs.Changes
src/input.rs— NewLoad::Url(String)variant and a case-insensitivelooks_like_url()helper. A positional arg matching an http(s) scheme resolves toLoad::Url; anything else staysLoad::File. Piped stdin still wins over both. Added unit tests for http/https, case-insensitivity, non-URL-stays-file, and stdin precedence.src/run.rs— New match armLoad::Url(url) => builder.with_url(url), loading the page directly (no custom protocol needed).src/cli.rs— Positionalvalue_nameis nowFILE|URL; updated doc comment, long help, and added awebview https://example.comexample.src/main.rs— Updated the no-input usage message.README.md— Documented URL input and updated the precedence note.Notes
Unlike file pages (served over the custom
wv://origin), a URL loads on its real remote origin. Thewindow.webviewbridge is still injected soresolve/rejectwork the same.Testing
cargo test— 26 tests passcargo clippy --all-targets -- -D warnings— cleancargo fmt --check— clean