Skip to content

Conversation

louonezime
Copy link
Contributor

@louonezime louonezime commented Jul 7, 2025

This PR introduces a new query package that provides reusable helpers for working with URL query strings. It is designed to simplify parsing, updating, and reconstructing query parameters in a clean and generic way.

This logic was originally embedded in the blog package (in #4324), but has now been extracted into its own utility package to promote reusability and separation of concerns.

  • ParseQueryParams(key, rawURL) → get a single query parameter value
  • ParseQueryMap(rawURL) → return all query parameters as a map[string]string
  • UpdateQuery(rawURL, key, value) → set or overwrite a single query param
  • UpdateQueryMulti(rawURL, map[string]string) → update multiple query params at once
  • DeleteQuery(rawURL, key) → remove a parameter from the query string

UPDATE

  • GetQueryValues – Get all values for a given key.
  • GetQueryFirstValue – Get the first value for a given key.
  • HasQueryKey – Check if a key exists in the query.
  • GetQueryValueFromURL – Retrieve a query value from a raw URL.
  • ParseQueryFirstValuesMap – Parse a URL into a map of first values.
  • UpdateQueryValue – Set a single value for a key.
  • UpdateQueryValues – Set multiple values for a single key.
  • UpdateQueryFirstValues – Set single values for multiple keys.
  • UpdateQueryAllValues – Set multiple values for multiple keys.
  • SetQueries – Replace or add keys with single values.
  • SetQueriesMulti – Replace or add keys with multiple values.
  • DeleteQuery – Remove a specific key from the query.
  • ResetQuery – Remove all query parameters from the URL.

@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 🤝 contribs labels Jul 7, 2025
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jul 7, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jul 7, 2025

🛠 PR Checks Summary

🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: louonezime/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied
└── 🔴 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🟢 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Then
        └── 🔴 And
            ├── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)
            └── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

@louonezime louonezime marked this pull request as draft July 7, 2025 10:51
@Gno2D2 Gno2D2 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jul 7, 2025
@louonezime louonezime marked this pull request as ready for review July 7, 2025 13:28
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jul 7, 2025
@notJoon
Copy link
Member

notJoon commented Jul 7, 2025

Could you check the action failures? Thank you

Seems like the CI failures dose not related with this PR. ignore this comment

Copy link

codecov bot commented Jul 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Member

@notJoon notJoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some suggestions, but implemtation looks good 👍

@louonezime louonezime requested a review from notJoon July 11, 2025 14:26
Copy link
Member

@notJoon notJoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

remove: review/triage-pending flag

@notJoon notJoon removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jul 12, 2025
@leohhhn leohhhn self-requested a review July 14, 2025 11:31
@leohhhn leohhhn merged commit eda1087 into gnolang:master Jul 15, 2025
73 of 75 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in 💪 Bounties & Worx Jul 15, 2025
Comment on lines +2 to +5
Package query provides a simple way to handle queries in your realm.

It includes helper functions to extract individual query parameters, convert the full query string into a map,
and update one or more parameters in a URL.
Copy link
Contributor

@leohhhn leohhhn Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would've been good to mention that is it specifically for queries, ie after ?. we've three possible things in the URL:

pkgpath:renderpath{?queries , $gnowebparams}

stefann-01 pushed a commit to stefann-01/gno that referenced this pull request Aug 26, 2025
This PR introduces a new query package that provides reusable helpers
for working with URL query strings. It is designed to simplify parsing,
updating, and reconstructing query parameters in a clean and generic
way.

This logic was originally embedded in the `blog` package (in
gnolang#4324), but has now been extracted
into its own utility package to promote reusability and separation of
concerns.

- ParseQueryParams(key, rawURL) → get a single query parameter value
- ParseQueryMap(rawURL) → return all query parameters as a
map[string]string
- UpdateQuery(rawURL, key, value) → set or overwrite a single query
param
- UpdateQueryMulti(rawURL, map[string]string) → update multiple query
params at once
- DeleteQuery(rawURL, key) → remove a parameter from the query string

*UPDATE*

- `GetQueryValues` – Get all values for a given key.
- `GetQueryFirstValue` – Get the first value for a given key.
- `HasQueryKey` – Check if a key exists in the query.
- `GetQueryValueFromURL` – Retrieve a query value from a raw URL.
- `ParseQueryFirstValuesMap` – Parse a URL into a map of first values.
- `UpdateQueryValue` – Set a single value for a key.
- `UpdateQueryValues` – Set multiple values for a single key.
- `UpdateQueryFirstValues` – Set single values for multiple keys.
- `UpdateQueryAllValues` – Set multiple values for multiple keys.
- `SetQueries` – Replace or add keys with single values.
- `SetQueriesMulti` – Replace or add keys with multiple values.
- `DeleteQuery` – Remove a specific key from the query.
- `ResetQuery` – Remove all query parameters from the URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤝 contribs 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants