Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
760245f
feat: allow single-label hostnames in ValidateURL and improve perform…
Yashbhu May 5, 2026
0c24c83
docs: update ValidateURL comment to reflect RFC 1123 support
Yashbhu May 5, 2026
bfb27e1
fix(utils): move domainNameRegex inside ValidateURL
Yashbhu May 8, 2026
3b3780c
fix(api): use direct logrus import to avoid undefined log error in CI
Yashbhu May 8, 2026
3e1fcb2
refactor(api): use fmt for user-facing output in instance_handler
Yashbhu May 8, 2026
6a2f3ae
fix(api): add missing log import in instance_handler
Yashbhu May 8, 2026
8ff6456
fix(api): remove logrus and failing log call in instance_handler
Yashbhu May 8, 2026
0b383b7
fix(api): parse RegistryID if provided in CreateProject
Yashbhu May 8, 2026
d58f57d
fix(api): implement registry-id parsing fix only
Yashbhu May 8, 2026
c591034
fix(api): restrict registry-id parsing to proxy cache projects
Yashbhu May 8, 2026
988dc04
revert: project_handler changes and restore log usage
Yashbhu May 9, 2026
15973e1
style: use fmt for project handler success messages
Yashbhu May 9, 2026
0184adf
fix: resolve linting issues and optimize regex compilation
Yashbhu May 15, 2026
ab17131
docs: add missing comments to exported validation functions
Yashbhu May 15, 2026
c7a93b9
fix: resolve linting issues in utils.go
Yashbhu May 16, 2026
7919a0a
fix: resolve compilation errors and formatting issues
Yashbhu May 16, 2026
9953f4a
fix: switch to fmt for logging in instance_handler to resolve CI error
Yashbhu May 16, 2026
20a05de
refactor: move regex back into functions to match project style
Yashbhu May 16, 2026
cbe2c7d
fix: allow single-label hostnames in ValidateURL and resolve linting …
Yashbhu May 16, 2026
9dc2e8b
fix: allow single-label hostnames in ValidateURL and restore original…
Yashbhu May 16, 2026
5d50c3e
chore: remove unnecessary documentation comments
Yashbhu May 16, 2026
e247462
chore: remove irrelevant storage limit comment
Yashbhu May 16, 2026
a764186
fix: allow single-label hostnames in ValidateURL and restore original…
Yashbhu May 16, 2026
46daf60
fix: allow single-label hostnames in ValidateURL and restore original…
Yashbhu May 16, 2026
149048f
fix: use logrus directly to resolve CI unused import error
Yashbhu May 16, 2026
3ad9e11
fix: use fmt.Printf to resolve persistent CI unused import error
Yashbhu May 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/instance_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func UpdateInstance(instanceName string, instance models.Instance) error {
return err
}

log.Infof("Instance %s updated", instance.Name)
fmt.Printf("Instance %s updated\n", instance.Name)
return nil
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ func ValidateRegistryName(rn string) bool {
return re.MatchString(rn)
}

// ValidateURL checks if the URL has valid format, non-empty host, and host is a valid IP or domain.
// Domain regex: labels must start/end with alphanumeric, can contain hyphens, max 63 chars, TLD min 2 letters.
// ValidateURL checks that the URL has a valid format and a non-empty host.
// The host may be an IP address, "localhost", or an RFC 1123-style hostname validated by domainNameRegex.
func ValidateURL(rawURL string) error {
var domainNameRegex = regexp.MustCompile(`^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$`)
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.

I dont know why are you moving removing the var from here - just to declare above the function.

That doesnt make sense - is there any specific reason to do this.

thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the only reason to move it outside i thought of is to avoid the overhead of re-compiling the regex on every call
though you are right to address it that in a CLI it's not much needed and rather clean code setup should be much prioritized i've reverted this
thanks !

pattern := `^(?i:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$`
domainNameRegex := regexp.MustCompile(pattern)

parsedURL, err := url.ParseRequestURI(rawURL)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/utils/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func TestValidateURL(t *testing.T) {
{"valid localhost https", "https://localhost", false},
{"valid localhost http with port", "http://localhost:8080", false},
{"valid localhost https with port", "https://localhost:8443", false},
{"valid single-label hostname", "http://harbor", false},
{"valid single-label with hyphen", "https://registry-server", false},
{"valid single-label with port", "http://harbor:8080", false},

// invalid URLs
{"empty string", "", true},
Expand Down
Loading