File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -457,8 +457,8 @@ func (p *PackageURL) Normalize() error {
457457 }
458458 subpath := strings .Trim (p .Subpath , "/" )
459459 segs := strings .Split (p .Subpath , "/" )
460- for _ , s := range segs {
461- if s == "." || s == ".." {
460+ for i , s := range segs {
461+ if ( s == "." || s == ".." ) && i != 0 {
462462 return fmt .Errorf ("invalid Package URL subpath: %q" , p .Subpath )
463463 }
464464 }
Original file line number Diff line number Diff line change @@ -486,6 +486,32 @@ func TestNormalize(t *testing.T) {
486486 Subpath : "/sub/../path/" ,
487487 },
488488 wantErr : true ,
489+ }, {
490+ name : "'./' is a valid subpath prefix" ,
491+ input : packageurl.PackageURL {
492+ Type : "npm" ,
493+ Name : "pkg" ,
494+ Subpath : "./sub/path" ,
495+ },
496+ want : packageurl.PackageURL {
497+ Type : "npm" ,
498+ Name : "pkg" ,
499+ Qualifiers : packageurl.Qualifiers {},
500+ Subpath : "./sub/path" ,
501+ },
502+ }, {
503+ name : "'../' is a valid subpath prefix" ,
504+ input : packageurl.PackageURL {
505+ Type : "npm" ,
506+ Name : "pkg" ,
507+ Subpath : "../sub/path" ,
508+ },
509+ want : packageurl.PackageURL {
510+ Type : "npm" ,
511+ Name : "pkg" ,
512+ Qualifiers : packageurl.Qualifiers {},
513+ Subpath : "../sub/path" ,
514+ },
489515 }, {
490516 name : "known type namespace adjustments" ,
491517 input : packageurl.PackageURL {
You can’t perform that action at this time.
0 commit comments