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 FromURL function in internal/glrepo/repo.go to use u.Host instead of u.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.go to include non-standard ports in host validation:

    • Fixed the existing "GDK with api_host" test case to expect gdk.test:3443 instead of gdk.test
    • Added a new test case "non-standard port without api_host" to verify URLs like https://example.com:8443/owner/repo correctly preserve the port

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

Merge request reports

Loading