diff --git a/pkg/buildpack/locator_type.go b/pkg/buildpack/locator_type.go index 0019cc900..de310e6c1 100644 --- a/pkg/buildpack/locator_type.go +++ b/pkg/buildpack/locator_type.go @@ -36,7 +36,7 @@ const ( var ( // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string semverPattern = `(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?` - registryPattern = regexp.MustCompile(`^[a-z0-9\-\.]+\/[a-z0-9\-\.]+(?:@` + semverPattern + `)?$`) + registryPattern = regexp.MustCompile(`^[a-z0-9\-\.]+(?::[0-9]+)?\/[a-z0-9\-\.]+(?:@` + semverPattern + `)?$`) ) func (l LocatorType) String() string { diff --git a/pkg/buildpack/locator_type_test.go b/pkg/buildpack/locator_type_test.go index bdc045373..690338420 100644 --- a/pkg/buildpack/locator_type_test.go +++ b/pkg/buildpack/locator_type_test.go @@ -155,6 +155,14 @@ func testGetLocatorType(t *testing.T, when spec.G, it spec.S) { locator: "example/registry-cnb", expectedType: buildpack.RegistryLocator, }, + { + locator: "localhost:5000/foo", + expectedType: buildpack.RegistryLocator, + }, + { + locator: "myregistry:8080/bar", + expectedType: buildpack.RegistryLocator, + }, { locator: "cnbs/sample-package@hello-universe", expectedType: buildpack.InvalidLocator,