Support URL-encoded JSON state, accept file input, rename browse→open, and show help when no args#1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 011eae0e84
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| let decoded = | ||
| urlencoding::decode(state).map_err(|err| LinkStateError::UrlDecode(err.to_string()))?; |
There was a problem hiding this comment.
When the input is a full URL, extract_state already returns a decoded query value via url.query_pairs(), but decode_state unconditionally applies urlencoding::decode again. This double-decoding breaks valid states that contain literal percent sequences: for example %25 in JSON becomes % after query parsing and then either errors (invalid URL encoding) or is transformed again (e.g. %2F -> /). As a result, some valid share links fail only in URL form while the same state string works directly.
Useful? React with 👍 / 👎.
Motivation
v2./base64/gzip decoding and only supporting URL-encoded JSONstatevalues.rtwith no arguments shows help rather than error, and rename thebrowsesubcommand to a cleareropenaction.Description
v2./base64/gzip decoding with URL-decoded JSON handling insrc/link_state.rssostateis treated as URL-encoded JSON only anddecode_statejust returns the URL-decoded string.arg_required_else_help = trueto theclapClidefinition and rename theBrowsesubcommand toOpeninsrc/main.rsto makertshow help when invoked without arguments and to usert opento open the editor URL.resolve_inputhelper insrc/lib.rsto detect when thelink_or_stateargument is a file path and read its (trimmed) contents, and introduce aReadInputFileerror variant for read failures.tests/cli.rsto reflect URL-encoded JSON inputs and addinput_file_is_acceptedto verify file-path input handling.README.mdexamples to show URL-encoded JSON, theopensubcommand, and file input usage.Testing
cargo test(unit and integration tests) after changes and all tests passed successfully.cargo build --releasewhich completed successfully.tests/cli.rs, including the newinput_file_is_acceptedtest, which passed.Codex Task