Skip to content

feat: use qs_dart in buildUrlString #158

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

techouse
Copy link

@techouse techouse commented Apr 30, 2025

👋 Hi there! I’m the author of qs_dart, a Dart port of qs for JavaScript.

I’ve given the buildUrlString utility method a thorough overhaul to boost its reliability and maintainability. Below is a summary of the key improvements:

🚀 Core Enhancements

  • Stricter URL Validation
  • Now raises an ArgumentError for malformed or non-HTTP(S) URLs
  • Relies on Dart’s Uri.parse and basic checks - no more ad-hoc string assumptions
  • Robust Query Encoding
  • Switched to the qs_dart library for all query-string serialization
  • Preserves existing multi-valued parameters and URL fragments

🛠️ New Dependencies

  • qs_dart (v1.3.5+1) – Advanced query-string encoding
  • validators (v3.0.0) – Optional URL format checks

✅ Expanded Test Coverage

Added new cases in test/utils/utils_test.dart to validate:

  • Parameter edge cases
  • null / empty maps, empty‐string values, overriding existing keys
  • URL integrity
  • Preserving fragments, rejecting invalid URLs
  • Encoding nuances
  • Special characters, reserved symbols (@, /), spaces vs. plus signs
  • Data types & collections
  • Numeric and boolean values, lists (including empty items), insertion-order guarantees

These tests ensure that buildUrlString behaves correctly across all common and edge scenarios.

@techouse
Copy link
Author

techouse commented May 1, 2025

@CodingAleCR I have added URL validation to the buildUrlString. If that's not desired, I can remove it.

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.

1 participant