Skip to content

fix(client): proper encoding such that [ get encoded instead of inter…#651

Merged
themaherkhalil merged 2 commits intodevfrom
fix-get-request-encoding
Mar 3, 2025
Merged

fix(client): proper encoding such that [ get encoded instead of inter…#651
themaherkhalil merged 2 commits intodevfrom
fix-get-request-encoding

Conversation

@themaherkhalil
Copy link
Copy Markdown
Contributor

…preted as arrays

@themaherkhalil themaherkhalil requested a review from a team as a code owner March 3, 2025 18:27
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2025

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

fix(client): proper encoding such that [ get encoded instead of inter…


User description

…preted as arrays


PR Type

  • Bug fix

Description

  • Fix GET request URL encoding issue.

  • Add custom paramsSerializer for query parameters.


Changes walkthrough 📝

Relevant files
Bug fix
monolith.store.ts
Add custom params serializer in MonolithStore.                     

packages/client/src/stores/monolith/monolith.store.ts

  • Added paramsSerializer function for proper URL encoding.
  • Encodes query parameter keys and values using encodeURIComponent.
  • +10/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Mar 3, 2025

    @CodiumAI-Agent /review

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Encoding Handling

    Review the custom paramsSerializer implementation to ensure it correctly handles edge cases, such as array values or nested objects, and maintains the expected formatting for URL parameters.

    paramsSerializer: (params) => {
        return Object.keys(params)
            .map(
                (key) =>
                    `${encodeURIComponent(
                        key,
                    )}=${encodeURIComponent(params[key])}`,
            )
            .join('&');
    },

    @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Mar 3, 2025

    @CodiumAI-Agent /improve

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Simplify encoding format

    Refactor the multi-line template literal in paramsSerializer to avoid unintended
    whitespace or newline characters in the query string.

    packages/client/src/stores/monolith/monolith.store.ts [2683-2685]

    -`${encodeURIComponent(
    -                                key,
    -                            )}=${encodeURIComponent(params[key])}`,
    +`${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`,
    Suggestion importance[1-10]: 5

    __

    Why: The suggestion proposes refactoring the multi-line template literal into a single line to avoid inadvertent whitespace in the query string. Although the impact is minor and mainly stylistic, it could help prevent subtle bugs, warranting a moderate score.

    Low

    @themaherkhalil themaherkhalil merged commit 0ecead5 into dev Mar 3, 2025
    2 checks passed
    @themaherkhalil themaherkhalil deleted the fix-get-request-encoding branch March 3, 2025 20:26
    @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Mar 3, 2025

    @CodiumAI-Agent /update_changelog

    @themaherkhalil themaherkhalil linked an issue Mar 12, 2025 that may be closed by this pull request
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Escape special characters in GET Requests

    2 participants