diff --git a/act/runner/reusable_workflow.go b/act/runner/reusable_workflow.go index e231e39f..9ef57d20 100644 --- a/act/runner/reusable_workflow.go +++ b/act/runner/reusable_workflow.go @@ -240,19 +240,3 @@ func newRemoteReusableWorkflowWithPlat(url, uses string) *remoteReusableWorkflow URL: url, } } - -// isSameInstance checks if two URLs/hosts refer to the same instance. -// Normalizes protocol prefixes, trailing slashes, and case. -func isSameInstance(urlOrHost, instance string) bool { - normalize := func(s string) string { - s = strings.TrimSpace(s) - s = strings.TrimSuffix(s, "/") - if strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") { - if u, err := url.Parse(s); err == nil && u.Host != "" { - return strings.ToLower(u.Host) - } - } - return strings.ToLower(s) - } - return normalize(urlOrHost) == normalize(instance) -} diff --git a/act/runner/urlutil.go b/act/runner/urlutil.go new file mode 100644 index 00000000..e7dcbd69 --- /dev/null +++ b/act/runner/urlutil.go @@ -0,0 +1,23 @@ +package runner + +import ( + "net/url" + "strings" +) + +// Normalizes protocol prefixes, trailing slashes, and case. +func normalizeHost(s string) string { + s = strings.TrimSpace(s) + s = strings.TrimSuffix(s, "/") + if strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") { + if u, err := url.Parse(s); err == nil && u.Host != "" { + return strings.ToLower(u.Host) + } + } + return strings.ToLower(s) +} + +// isSameInstance checks if two URLs/hosts refer to the same instance. +func isSameInstance(urlOrHost, instance string) bool { + return normalizeHost(urlOrHost) == normalizeHost(instance) +}