File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,7 @@ module.exports = {
212212 )
213213 } ,
214214 // https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#golang
215- golang ( purl ) {
215+ golang ( purl , throws ) {
216216 // Still being lenient here since the standard changes aren't official.
217217 // Pending spec change: https://github.com/package-url/purl-spec/pull/196
218218 const { version } = purl
Original file line number Diff line number Diff line change @@ -545,4 +545,52 @@ describe('PackageURL', function () {
545545 )
546546 } )
547547 } )
548+
549+ describe ( 'golang' , function ( ) {
550+ it ( 'should throw an error for invalid semver version starting with v' , function ( ) {
551+ assert . throws (
552+ ( ) =>
553+ new PackageURL (
554+ 'golang' ,
555+ 'github.com' ,
556+ 'example/pkg' ,
557+ 'v1.0.invalid'
558+ ) ,
559+ / g o l a n g " v e r s i o n " c o m p o n e n t s t a r t i n g w i t h a " v " m u s t b e f o l l o w e d b y a v a l i d s e m v e r v e r s i o n /
560+ )
561+ } )
562+
563+ it ( 'should allow valid semver version starting with v' , function ( ) {
564+ assert . doesNotThrow ( ( ) => {
565+ new PackageURL (
566+ 'golang' ,
567+ 'github.com' ,
568+ 'example/pkg' ,
569+ 'v1.0.0'
570+ )
571+ } )
572+ } )
573+
574+ it ( 'should allow pseudo-version numbers' , function ( ) {
575+ assert . doesNotThrow ( ( ) => {
576+ new PackageURL (
577+ 'golang' ,
578+ 'github.com/cncf/xds' ,
579+ 'go' ,
580+ 'v0.0.0-20210922020428-25de7278fc84'
581+ )
582+ } )
583+ } )
584+
585+ it ( 'should allow versions without v prefix' , function ( ) {
586+ assert . doesNotThrow ( ( ) => {
587+ new PackageURL (
588+ 'golang' ,
589+ 'github.com' ,
590+ 'example/pkg' ,
591+ 'abc123'
592+ )
593+ } )
594+ } )
595+ } )
548596} )
You can’t perform that action at this time.
0 commit comments