ocilayout: narrow Windows drive path detection
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package ocilayout
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/distribution/reference"
|
||||
@@ -59,10 +60,8 @@ func (r Ref) String() string {
|
||||
return s
|
||||
}
|
||||
|
||||
var windowsDrivePath = regexp.MustCompile(`^[A-Za-z]:[\\/]`)
|
||||
|
||||
func isWindowsDrivePath(path string, colon int) bool {
|
||||
if colon != 1 || len(path) < 2 {
|
||||
return false
|
||||
}
|
||||
c := path[0]
|
||||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
|
||||
return colon == 1 && windowsDrivePath.MatchString(path)
|
||||
}
|
||||
|
||||
@@ -40,11 +40,21 @@ func TestParse(t *testing.T) {
|
||||
path: "/path/to/oci/@/layout",
|
||||
tag: "latest",
|
||||
},
|
||||
{
|
||||
s: "oci-layout://a:1.3",
|
||||
path: "a",
|
||||
tag: "1.3",
|
||||
},
|
||||
{
|
||||
s: `oci-layout://C:\path\to\oci\layout`,
|
||||
path: `C:\path\to\oci\layout`,
|
||||
tag: "latest",
|
||||
},
|
||||
{
|
||||
s: `oci-layout://C:/path/to/oci/layout`,
|
||||
path: `C:/path/to/oci/layout`,
|
||||
tag: "latest",
|
||||
},
|
||||
{
|
||||
s: `oci-layout://C:\path\to\oci\layout:1.3`,
|
||||
path: `C:\path\to\oci\layout`,
|
||||
|
||||
Reference in New Issue
Block a user