From 52c62bd13b265c7ac24690080f48717c071a5f77 Mon Sep 17 00:00:00 2001 From: David Dooling Date: Thu, 18 Jan 2024 14:10:15 -0600 Subject: [PATCH] Fix isGitURL regular expression Escape period (.) so regular expression does not match any character before "git". Signed-off-by: David Dooling --- cli/command/image/build/internal/urlutil/urlutil.go | 2 +- cli/command/image/build/internal/urlutil/urlutil_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/command/image/build/internal/urlutil/urlutil.go b/cli/command/image/build/internal/urlutil/urlutil.go index e38988a30c..e8459cc820 100644 --- a/cli/command/image/build/internal/urlutil/urlutil.go +++ b/cli/command/image/build/internal/urlutil/urlutil.go @@ -12,7 +12,7 @@ import ( // urlPathWithFragmentSuffix matches fragments to use as Git reference and build // context from the Git repository. See IsGitURL for details. -var urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$") +var urlPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`) // IsURL returns true if the provided str is an HTTP(S) URL by checking if it // has a http:// or https:// scheme. No validation is performed to verify if the diff --git a/cli/command/image/build/internal/urlutil/urlutil_test.go b/cli/command/image/build/internal/urlutil/urlutil_test.go index 6906118321..ed39f5f22e 100644 --- a/cli/command/image/build/internal/urlutil/urlutil_test.go +++ b/cli/command/image/build/internal/urlutil/urlutil_test.go @@ -17,6 +17,7 @@ var ( } invalidGitUrls = []string{ "http://github.com/docker/docker.git:#branch", + "https://github.com/docker/dgit", } )