File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -12,18 +12,21 @@ var doi = module.exports = function (opts) {
12
12
}
13
13
14
14
doi . groups = function ( str ) {
15
+ if ( ! str ) { return }
15
16
// Javascript fails at lookaheads for optional groups. This circumvents that
16
17
// problem by just automatically removing and saving suffixes if they are in
17
18
// as specific format - .a000 is the format used by PLoS, but this may need
18
19
// to be filled out.
19
- var suffixes = [ ] ;
20
- var newStr = str . replace ( / \. [ a - z A - Z ] { 1 } [ 0 - 9 ] { 3 } $ / g, function ( s ) {
20
+ var suffixes = [ ]
21
+ var newStr = str . replace ( / \. [ a - z A - Z ] { 1 } [ 0 - 9 ] { 3 } $ / g, function ( s ) {
21
22
suffixes . push ( s )
22
23
return ''
23
24
} )
24
25
var match = doi ( ) . exec ( newStr )
25
- match [ 0 ] = str ;
26
- match . push ( ( ! ! suffixes . length ) ? suffixes [ 0 ] : '' )
26
+ if ( match ) {
27
+ match [ 0 ] = str
28
+ match . push ( ( ! ! suffixes . length ) ? suffixes [ 0 ] : '' )
29
+ }
27
30
return match
28
31
}
29
32
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " doi-regex" ,
3
- "version" : " 0.0.2 " ,
3
+ "version" : " 0.0.3 " ,
4
4
"description" : " Regular expression for matching DOIs" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
You can’t perform that action at this time.
0 commit comments