-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Replace url segment #2313
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
Replace url segment #2313
Conversation
- Multiple query parameters with the same name - Query parameters with non-string values
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
|
Fixes #2300 |
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
Test Results 35 files 35 suites 15m 50s ⏱️ Results for commit 9a54720. |
User description
Description
Changes the default of
AddUrlSegmentto replace the parameter rather than adding it.The reason for this change is that URL segments are unique, so adding more parameters with the same name has no effect as only the first one will be used. It's different from query or header parameters which allow multiple values for the same name.
It might be considered as a "breaking change" because when
AddUrlSegmentis called multiple times for the same parameter name, only the first value is used today. However, it makes the library easier to use, and the existing behaviour is meaningless anyway.Checklist
PR Type
Enhancement
Description
Change
AddUrlSegmentto replace existing parameter instead of adding duplicateURL segments are unique identifiers, so multiple values with same name are meaningless
Add tests for URL segment replacement and query parameter handling
Simplify library behavior for URL segment parameters
Diagram Walkthrough
File Walkthrough
RestRequestExtensions.Url.cs
Replace AddParameter with AddOrUpdateParameter callsrc/RestSharp/Request/RestRequestExtensions.Url.cs
AddUrlSegmentmethod to callAddOrUpdateParameterinstead ofAddParameterduplicated
UrlSegmentTests.cs
Add URL segment replacement behavior testtest/RestSharp.Tests/Parameters/UrlSegmentTests.cs
AddSameUrlSegmentTwice_ShouldReplaceFirstto verifyreplacement behavior
first
UrlBuilderTests.Get.cs
Add query parameter handling teststest/RestSharp.Tests/UrlBuilderTests.Get.cs
Multiple_query_parameters_with_same_nameto verify queryparameters allow duplicates
Query_parameter_with_non_string_valueto verify non-stringparameter values work correctly