Repository navigation
Add Link#_query to send undeclared query parameters - #334
Merged
Merged
Conversation
HAL templated links only expand the variables they declare, so callers had no way to send extra query parameters, or any parameters on a link that is not templated. `_query(params)` returns a new link with the parameters appended to its URL after any existing query string, keeps them across `_expand`, repeats array values and drops nil values. `_expand` stays strict. Closes codegram#84. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Gr21mVM7TZeZyebArnTs9
Contributor
Danger ReportNo issues found. |
Merged
dblock
added a commit
that referenced
this pull request
Nov 21, 2026
Link#_query (#334) is a backward-compatible feature, so the next release is a minor version. Move the changelog placeholder below the entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Gr21mVM7TZeZyebArnTs9
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.
HAL templated links only expand the variables they declare, and
_expanddrops anything else (as documented in the README). That left no way to send extra query parameters, such as asortthe API accepts but doesn't declare, or any parameters on a link that isn't templated (#84).This adds
Link#_query(params), which returns a new link with the parameters appended to its URL:_expandin either order.hrefare preserved (it doesn't round-trip throughAddressable::URI#query_values, which drops repeated keys and sorts).FlatParamsEncoderused by the connection;nilvalues are dropped, like undefined template variables._expandstays strict, so existing behavior is unchanged.This supersedes #92 (2015), which patched
URITemplateto expand undeclared variables by default; Hyperclient has since moved to Addressable and that patch no longer applies.Closes #84.
Validation
bundle exec rakeon Ruby 4.0.9: Minitest 171 runs, 0 failures; Spinach 32 steps passed; RuboCop 34 files, no offenses._querytests fail againstmaster'slink.rband pass with this change.examples/oxford/server.rb); the server loggedGET /places/?sort=nameandGET /places/oxpoints%3A23232339?fields=name.This PR was written by an AI (Claude) acting on behalf of @dblock.
🤖 Generated with Claude Code
https://claude.ai/code/session_011Gr21mVM7TZeZyebArnTs9