Skip to content

Remove util.URLJoin and replace all callers with direct path concatenation#36867

Merged
wxiaoguang merged 2 commits intomainfrom
copilot/remove-util-urljoin-function
Mar 8, 2026
Merged

Remove util.URLJoin and replace all callers with direct path concatenation#36867
wxiaoguang merged 2 commits intomainfrom
copilot/remove-util-urljoin-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 8, 2026

util.URLJoin was deprecated with unclear semantics (path normalization via url.Parse/ResolveReference that surprised callers). This removes it entirely and replaces all usages with straightforward "/" string concatenation.

Changes

  • modules/util/url.go: Delete URLJoin and its unused path import
  • modules/util/util_test.go: Delete TestURLJoin
  • services/convert/git_commit_test.go: headRepo.APIURL() + "/git/commits/" + sha — remove util import
  • tests/integration/api_repo_git_tags_test.go: repo.APIURL() + "/git/tags/" + id — remove util import
  • tests/integration/api_packages_rpm_test.go: strings.TrimSuffix(setting.AppURL, "/") + groupURL — remove util import
  • modules/markup/html_internal_test.go: Update externalIssueLink/numericIssueLink helpers to use strings.TrimSuffix(baseURL, "/") + "/" + elem; replace remaining direct calls
  • modules/markup/html_test.go: Replace all util.URLJoin calls with direct concatenation

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 8, 2026
…atenation

Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove util.URLJoin and refactor its usage Remove util.URLJoin and replace all callers with direct path concatenation Mar 8, 2026
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 8, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 8, 2026
@wxiaoguang wxiaoguang marked this pull request as ready for review March 8, 2026 16:41
@silverwind
Copy link
Copy Markdown
Member

Some replacements assume the base URL ends with / (e.g. TestRepoURL + "issues/3333" in html_test.go), while others defensively strip it with strings.TrimSuffix(baseURL, "/") (e.g. html_internal_test.go, api_packages_rpm_test.go). This works because TestRepoURL and TestAppURL are known constants ending with /, but it's fragile — if those constants ever change, the bare concatenations would produce double slashes. Consider using TrimSuffix consistently.

— written by Claude

@silverwind
Copy link
Copy Markdown
Member

1 minor concern from Claude, otherwise looking good.

@wxiaoguang
Copy link
Copy Markdown
Contributor

"test code" only.

These tests already have a lot of problems, most of them need to be rewritten.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 8, 2026
@wxiaoguang wxiaoguang merged commit 80c57ec into main Mar 8, 2026
30 checks passed
@wxiaoguang wxiaoguang deleted the copilot/remove-util-urljoin-function branch March 8, 2026 18:30
@GiteaBot GiteaBot added this to the 1.26.0 milestone Mar 8, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Mar 8, 2026
* main: (26 commits)
  Clean up `refreshViewedFilesSummary` (go-gitea#36868)
  Remove `util.URLJoin` and replace all callers with direct path concatenation (go-gitea#36867)
  Optimize Docker build with dependency layer caching (go-gitea#36864)
  Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861)
  Fix CodeQL code scanning alerts (go-gitea#36858)
  Refactor auth middleware (go-gitea#36848)
  Update Nix flake (go-gitea#36857)
  Update JS deps (go-gitea#36850)
  Load `mentionValues` asynchronously (go-gitea#36739)
  [skip ci] Updated translations via Crowdin
  Fix dbfs error handling (go-gitea#36844)
  Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797)
  Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798)
  Fix non-admins unable to automerge PRs from forks (go-gitea#36833)
  upgrade to github.com/cloudflare/circl 1.6.3, svgo 4.0.1, markdownlint-cli 0.48.0 (go-gitea#36837)
  Fix dump release asset bug (go-gitea#36799)
  build(deps): update material-icon-theme v5.32.0 (go-gitea#36832)
  Fix bug to check whether user can update pull request branch or rebase branch (go-gitea#36465)
  Fix forwarded proto handling for public URL detection (go-gitea#36810)
  Fix artifacts v4 backend upload problems (go-gitea#36805)
  ...

# Conflicts:
#	pnpm-lock.yaml
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 10, 2026
* giteaofficial/main:
  Update minimum go version to 1.26.1, golangci-lint to 2.11.2, fix test style (go-gitea#36876)
  Add render cache for SVG icons (go-gitea#36863)
  Fix incorrect viewed files counter if reverted change was viewed (go-gitea#36819)
  [skip ci] Updated translations via Crowdin
  Clean up `refreshViewedFilesSummary` (go-gitea#36868)
  Remove `util.URLJoin` and replace all callers with direct path concatenation (go-gitea#36867)
  Optimize Docker build with dependency layer caching (go-gitea#36864)
  Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861)
  Fix CodeQL code scanning alerts (go-gitea#36858)
  Refactor auth middleware (go-gitea#36848)
  Update Nix flake (go-gitea#36857)
  Update JS deps (go-gitea#36850)
  Load `mentionValues` asynchronously (go-gitea#36739)
  [skip ci] Updated translations via Crowdin
  Fix dbfs error handling (go-gitea#36844)
  Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797)
  Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants