Skip to content

fix(common): omit trailing ? in URL.String() without query params#3328

Open
leno23 wants to merge 1 commit into
apache:mainfrom
leno23:fix/url-string-no-trailing-query-3327
Open

fix(common): omit trailing ? in URL.String() without query params#3328
leno23 wants to merge 1 commit into
apache:mainfrom
leno23:fix/url-string-no-trailing-query-3327

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • URL.String() no longer appends a bare ? when the URL has no parameters.
  • Added TestURLStringWithoutQuery regression test.

Fixes #3327.

Test plan

  • go test ./common/... -run TestURLString

@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented May 17, 2026

pls provide the demonstration before and after edit

@Alanxtl Alanxtl added 🧹 Updates 3.3.2 version 3.3.2 labels May 17, 2026
Closes apache#3327. Only append a query string when URL parameters exist.
@leno23 leno23 force-pushed the fix/url-string-no-trailing-query-3327 branch from be514dc to 5ffbee8 Compare May 17, 2026 14:27
@sonarqubecloud
Copy link
Copy Markdown

@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented May 23, 2026

pls fix ci fail

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes URL.String() to omit the trailing ? when there are no query parameters, addressing issue #3327.

Changes:

  • Removed the unconditional ? suffix in the URL prefix and only append ? when encoded params are non-empty.
  • Added TestURLStringWithoutQuery regression test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
common/url.go Conditionally append ? and params only when params are non-empty.
common/url_test.go New regression test verifying no trailing ? when there are no query parameters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented Jun 7, 2026

any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 优化 url.go 中 URL.String() 的输出格式

3 participants