Skip to content

Commit 768146b

Browse files
committed
Fix isGitURL regular expression
Escape period (.) so regular expression does not match any character before "git". Signed-off-by: David Dooling <[email protected]>
1 parent 615dfdf commit 768146b

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

builder/remotecontext/urlutil/urlutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// urlPathWithFragmentSuffix matches fragments to use as Git reference and build
1414
// context from the Git repository. See IsGitURL for details.
15-
var urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
15+
var urlPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
1616

1717
// IsURL returns true if the provided str is an HTTP(S) URL by checking if it
1818
// has a http:// or https:// scheme. No validation is performed to verify if the

builder/remotecontext/urlutil/urlutil_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var (
1717
}
1818
invalidGitUrls = []string{
1919
"http://github.com/docker/docker.git:#branch",
20+
"https://github.com/docker/dgit",
2021
}
2122
)
2223

0 commit comments

Comments
 (0)