File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import type { AuthorParserOptions } from 'types' ;
2
2
3
3
export class AuthorParser {
4
- private readonly AUTHOR_SEPARATORS = / , \s * a n d \s * | \s + a n d \s + | , \s * / ;
4
+ /** Matches common separators between author names: comma-and, and, or comma */
5
+ private readonly AUTHOR_SEPARATORS = / (?: , \s * a n d \s * ) | (?: \s + a n d \s + ) | (?: , \s * ) / ;
6
+ /** Matches common English titles at the start of a name */
5
7
private readonly TITLES = / ^ ( d r | p r o f | m r | m r s | m s | m i s s | s i r | l a d y ) \. \s + / i;
6
8
7
9
constructor ( private options : AuthorParserOptions = { } ) {
@@ -24,7 +26,12 @@ export class AuthorParser {
24
26
return authorString
25
27
. split ( this . AUTHOR_SEPARATORS )
26
28
. map ( author => this . processAuthor ( author ) )
27
- . filter ( Boolean ) ;
29
+ . filter ( author => {
30
+ if ( ! author ) {
31
+ return false ;
32
+ }
33
+ return true ;
34
+ } ) ;
28
35
}
29
36
30
37
/**
You can’t perform that action at this time.
0 commit comments