fix(glrepo): use Host instead of Hostname in FromURL function
Description
This MR fixes an issue where url.Hostname() was stripping the port number from URLs containing non-standard ports (e.g., https://gdk.test:3443/).
Changes made:
-
fix(glrepo): Updated the
FromURLfunction ininternal/glrepo/repo.goto useu.Hostinstead ofu.Hostname(). This preserves the port number when present in the URL, which is necessary for self-hosted GitLab instances running on non-standard ports. -
test(glrepo): Updated tests in
internal/glrepo/repo_test.goto include non-standard ports in host validation:- Fixed the existing "GDK with api_host" test case to expect
gdk.test:3443instead ofgdk.test - Added a new test case "non-standard port without api_host" to verify URLs like
https://example.com:8443/owner/repocorrectly preserve the port
- Fixed the existing "GDK with api_host" test case to expect
Related Issues
Resolves #8022 (closed)
How has this been tested?
This has been tested locally with unit tests that verify:
- URLs with non-standard ports (e.g.,
:3443,:8443) correctly preserve the port in the host - Standard URLs without explicit ports continue to work as expected
Edited by Swapnaneel Patra