Pārlūkot izejas kodu

Merge pull request #47136 from thaJeztah/25.0_backport_git-url-regex

[25.0 backport] Fix isGitURL regular expression
Sebastiaan van Stijn 1 gadu atpakaļ
vecāks
revīzija
c2847b2eb2

+ 1 - 1
builder/remotecontext/urlutil/urlutil.go

@@ -12,7 +12,7 @@ import (
 
 
 // urlPathWithFragmentSuffix matches fragments to use as Git reference and build
 // urlPathWithFragmentSuffix matches fragments to use as Git reference and build
 // context from the Git repository. See IsGitURL for details.
 // 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
 // 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
 // has a http:// or https:// scheme. No validation is performed to verify if the

+ 1 - 0
builder/remotecontext/urlutil/urlutil_test.go

@@ -17,6 +17,7 @@ var (
 	}
 	}
 	invalidGitUrls = []string{
 	invalidGitUrls = []string{
 		"http://github.com/docker/docker.git:#branch",
 		"http://github.com/docker/docker.git:#branch",
+		"https://github.com/docker/dgit",
 	}
 	}
 )
 )