@@ -29,6 +29,11 @@ function splitQualifierList(raw: string): string[] {
2929 . filter ( ( part ) => part . length > 0 ) ;
3030}
3131
32+ /** `me` and `@me` both name the viewer; logins are case-insensitive. */
33+ function authorKey ( login : string ) : string {
34+ return login . toLowerCase ( ) . replace ( / ^ @ m e $ / , "me" ) ;
35+ }
36+
3237function boundedNames ( names : ReadonlyArray < string > ) : string [ ] {
3338 return names
3439 . slice ( 0 , MAX_QUALIFIER_VALUES )
@@ -43,7 +48,8 @@ export function parsePullRequestQuery(raw: string): {
4348 const text : string [ ] = [ ] ;
4449 const labels : string [ ] [ ] = [ ] ;
4550 const excludedLabels : string [ ] = [ ] ;
46- let author : string | undefined ;
51+ // `null` once two different logins are named: GitHub ORs them, the contract carries one.
52+ let author : string | null | undefined ;
4753 let draft : PullRequestListFilters [ "draft" ] ;
4854 let review : PullRequestListFilters [ "review" ] ;
4955 let checks : PullRequestListFilters [ "checks" ] ;
@@ -59,13 +65,16 @@ export function parsePullRequestQuery(raw: string): {
5965 else labels . push ( names ) ;
6066 continue ;
6167 }
62- case "author" :
68+ case "author" : {
6369 if ( negated ) break ;
64- author = value . slice ( 0 , MAX_QUALIFIER_LENGTH ) . trim ( ) ;
70+ const login = value . slice ( 0 , MAX_QUALIFIER_LENGTH ) . trim ( ) ;
71+ if ( author === undefined ) author = login ;
72+ else if ( author === null || authorKey ( author ) !== authorKey ( login ) ) author = null ;
6573 continue ;
74+ }
6675 case "draft" :
67- if ( negated || ( value . toLowerCase ( ) !== "true" && value . toLowerCase ( ) !== "false" ) ) break ;
68- draft = value . toLowerCase ( ) === "true" ? "only" : "hide" ;
76+ if ( value . toLowerCase ( ) !== "true" && value . toLowerCase ( ) !== "false" ) break ;
77+ draft = ( value . toLowerCase ( ) === "true" ) !== negated ? "only" : "hide" ;
6978 continue ;
7079 case "review" : {
7180 const decision = negated ? undefined : REVIEW_VALUES [ value . toLowerCase ( ) ] ;
@@ -80,6 +89,15 @@ export function parsePullRequestQuery(raw: string): {
8089 checks = state ;
8190 continue ;
8291 }
92+ // GitHub's own search qualifiers, not labels: the list sets scope and order itself.
93+ case "is" :
94+ case "archived" :
95+ case "state" :
96+ case "repo" :
97+ case "org" :
98+ case "user" :
99+ case "sort" :
100+ continue ;
83101 case "" :
84102 break ;
85103 default :
@@ -104,7 +122,7 @@ export function parsePullRequestQuery(raw: string): {
104122 ...( excludedLabels . length === 0
105123 ? { }
106124 : { excludedLabels : excludedLabels . slice ( 0 , MAX_QUALIFIER_VALUES ) } ) ,
107- ...( author === undefined ? { } : { author } ) ,
125+ ...( typeof author === "string" ? { author } : { } ) ,
108126 ...( draft === undefined ? { } : { draft } ) ,
109127 ...( review === undefined ? { } : { review } ) ,
110128 ...( checks === undefined ? { } : { checks } ) ,
0 commit comments