Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add Uri extension #18

Merged
merged 3 commits into from
May 18, 2024
Merged

✨ add Uri extension #18

merged 3 commits into from
May 18, 2024

Conversation

techouse
Copy link
Owner

Description

Add an Uri extension which provides the following 2 methods:

/// The URI query split into a map.
/// Providing custom [options] will override the default behavior.
Map<String, dynamic> Uri.queryParametersQs([DecodeOptions options = const DecodeOptions()]);

/// The normalized string representation of the URI.
/// Providing custom [options] will override the default behavior.
String Uri.toStringQs(EncodeOptions options = const EncodeOptions());

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Added a suite od tests testing both methods extensively.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@techouse techouse added the enhancement New feature or request label May 18, 2024
@techouse techouse self-assigned this May 18, 2024
Copy link

coderabbitai bot commented May 18, 2024

Walkthrough

The recent update introduces a new extension on the Uri class within the qs_dart package. This extension, named UriExtension, adds methods for handling URI query parameters more efficiently. Specifically, it includes methods to decode and encode query parameters as maps and to obtain a normalized string representation of the URI with custom options.

Changes

File Change Summary
lib/qs_dart.dart Added export for src/uri.dart
lib/src/uri.dart Introduced UriExtension on Uri class with methods queryParametersQs and toStringQs

🐇
In the land of code, where bytes do gleam,
A rabbit's dream in a digital stream.
With URIs now more clear and bright,
Query strings dance in the moonlight.
Encode, decode, with ease they flow,
In qs_dart, the magic grows.
🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.38% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5fe6566) 637 622 97.65%
Head commit (e67c85e) 659 (+22) 641 (+19) 97.27% (-0.38%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#18) 6 6 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5fe6566 and e67c85e.
Files selected for processing (3)
  • lib/qs_dart.dart (1 hunks)
  • lib/src/uri.dart (1 hunks)
  • test/unit/uri_extension_test.dart (1 hunks)
Files not summarized due to errors (1)
  • test/unit/uri_extension_test.dart: Error: Message exceeds token limit
Files skipped from review due to trivial changes (1)
  • lib/qs_dart.dart
Additional comments not posted (4)
lib/src/uri.dart (2)

3-9: The implementation and documentation of queryParametersQs are clear and efficient.


11-18: The implementation and documentation of toStringQs are well-executed, ensuring the URI is correctly formatted.

test/unit/uri_extension_test.dart (2)

16-1000: Comprehensive test coverage for Uri.queryParametersQs.

The tests thoroughly cover a wide range of scenarios, including simple parsing, handling of special characters, and complex nested structures. This ensures robust validation of the method's functionality.


1507-1525: Effective testing of Uri.toStringQs.

The tests for Uri.toStringQs effectively validate the method's ability to handle different types of input, including special characters and symbols, ensuring accurate URL encoding.

@techouse techouse merged commit ba89462 into main May 18, 2024
12 checks passed
@techouse techouse deleted the feat/uri-extension branch May 18, 2024 18:25
techouse added a commit that referenced this pull request May 18, 2024
## 1.2.0

- [FEAT] `QS.decode` returns `Map<String, dynamic>` instead of `Map<dynamic, dynamic>` ([#17](#17))
- [FEAT] add `Uri` extension ([#18](#18))
- [FIX] fix decoding encoded square brackets in key names
@techouse techouse mentioned this pull request May 18, 2024
techouse added a commit that referenced this pull request May 18, 2024
## 1.2.0

- #17
- #18
- fix decoding encoded square brackets in key names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant