Skip to content

fix(util/host-rules): compare normalized URLs when matching hostRules#36311

Merged
rarkins merged 2 commits intorenovatebot:mainfrom
Shegox:match-host
Jun 5, 2025
Merged

fix(util/host-rules): compare normalized URLs when matching hostRules#36311
rarkins merged 2 commits intorenovatebot:mainfrom
Shegox:match-host

Conversation

@Shegox
Copy link
Copy Markdown
Contributor

@Shegox Shegox commented Jun 4, 2025

Changes

This PR modifies the matching behavior of http(s):// hostRules. Instead of using a basic string comparison, it now creates a URL object from the hostRule and compares the normalized .href value.

Context

This change prevents hostRule confusion and prevents unintended application to incorrect hosts.

For example, https://test will no longer match https://test.example.com because the .href adds a trailing /, making the comparison https://test/ vs. https://test.example.com/.
Similarly, https://example.com will not match https://example.com:8080, although it will match the standard port (https://example.com:443). Consequently, changes were made to the queue and throttle tests to set domain-level hosts appropriately.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

rarkins
rarkins previously approved these changes Jun 4, 2025
@rarkins rarkins requested review from secustor and viceice June 4, 2025 14:42
Copy link
Copy Markdown
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

otherwise LGTM

Comment thread lib/util/host-rules.ts Outdated
@rarkins rarkins enabled auto-merge June 4, 2025 14:57
@Shegox Shegox requested a review from viceice June 4, 2025 15:01
@rarkins rarkins added this pull request to the merge queue Jun 5, 2025
Merged via the queue into renovatebot:main with commit b7347fd Jun 5, 2025
40 checks passed
@Shegox Shegox deleted the match-host branch June 10, 2025 09:15
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants