Skip to content

feat: allow localhost as a valid host in URL validation#785

Merged
bupd merged 1 commit into
goharbor:mainfrom
marwan562:fix/allow-localhost-login
Apr 7, 2026
Merged

feat: allow localhost as a valid host in URL validation#785
bupd merged 1 commit into
goharbor:mainfrom
marwan562:fix/allow-localhost-login

Conversation

@marwan562

Copy link
Copy Markdown
Contributor

Description

This pull request modifies the ValidateURL function to allow localhost as a valid host. Previously, local development addresses lacking a top-level domain (like localhost or http://localhost:8080) failed the domain validation regex, which prevented users from successfully logging into local Harbor instances.

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • Added an early return check for "localhost" in pkg/utils/helper.go's ValidateURL function before the strict domain regex is evaluated.
  • Expanded the URL validation test suite in pkg/utils/helper_test.go to include coverage for localhost addresses using both HTTP and HTTPS schemes, as well as with and without ports.

Signed-off-by: marwan562 <mixing.gamer546@gmail.com>
@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 7.82%. Comparing base (60ad0bd) to head (b87cd21).
⚠️ Report is 130 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #785      +/-   ##
=========================================
- Coverage   10.99%   7.82%   -3.17%     
=========================================
  Files         173     270      +97     
  Lines        8671   13163    +4492     
=========================================
+ Hits          953    1030      +77     
- Misses       7612   12020    +4408     
- Partials      106     113       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NucleoFusion NucleoFusion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm
Thanks for the contribution

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@bupd bupd merged commit 0059692 into goharbor:main Apr 7, 2026
7 of 8 checks passed
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.

Allow localhost as valid server address in login

3 participants