File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -74,13 +74,22 @@ class PackageURL {
74
74
_handlePyPi ( ) {
75
75
this . name = this . name . toLowerCase ( ) . replace ( / _ / g, '-' ) ;
76
76
}
77
+ _handlePub ( ) {
78
+ this . name = this . name . toLowerCase ( ) ;
79
+ if ( ! / ^ [ a - z 0 - 9 _ ] + $ / i. test ( this . name ) ) {
80
+ throw new Error ( 'Invalid purl: contains an illegal character.' ) ;
81
+ }
82
+ }
77
83
78
84
toString ( ) {
79
85
var purl = [ 'pkg:' , encodeURIComponent ( this . type ) , '/' ] ;
80
86
81
87
if ( this . type === 'pypi' ) {
82
88
this . _handlePyPi ( ) ;
83
89
}
90
+ if ( this . type === 'pub' ) {
91
+ this . _handlePub ( ) ;
92
+ }
84
93
85
94
if ( this . namespace ) {
86
95
purl . push (
Original file line number Diff line number Diff line change 323
323
"subpath" : null ,
324
324
"is_invalid" : true
325
325
},
326
+ {
327
+ "description" : " checks for invalid characters" ,
328
+ "purl" : " pkg:pub/flutter_downloader@1.0.0" ,
329
+ "canonical_purl" : " pkg:pub/flutter_downloader@1.0.0" ,
330
+ "type" : " pub" ,
331
+ "namespace" : null ,
332
+ "name" : " flutter_downloader" ,
333
+ "version" : " 1.0.0" ,
334
+ "qualifiers" : null ,
335
+ "subpath" : null ,
336
+ "is_invalid" : false
337
+ },
338
+ {
339
+ "description" : " checks for invalid characters" ,
340
+ "purl" : " pkg:pub/flutter--downloader@1.0.0" ,
341
+ "canonical_purl" : " pkg:pub/flutter--downloader@1.0.0" ,
342
+ "type" : " pub" ,
343
+ "namespace" : null ,
344
+ "name" : null ,
345
+ "version" : null ,
346
+ "qualifiers" : null ,
347
+ "subpath" : null ,
348
+ "is_invalid" : true
349
+ },
326
350
{
327
351
"description" : " namespace can contain special characters" ,
328
352
"purl" : " pkg:npm/%40foo%40%3F%23/bar@1.0.0" ,
You can’t perform that action at this time.
0 commit comments