@@ -31,6 +31,28 @@ describe("GitLab change request URLs", () => {
3131 expect ( parse ( "https://gitlab.com/t3code/-/merge_requests/12" ) ) . toBeNull ( ) ;
3232 } ) ;
3333
34+ it ( "recognizes only merge request URLs it can parse" , ( ) => {
35+ for ( const url of [
36+ "https://gitlab.com/g/p?x=/-/merge_requests/5" ,
37+ "https://gitlab.com/g/p#/-/merge_requests/5" ,
38+ "https://gitlab.com?x=/g/p/-/merge_requests/5" ,
39+ "https://gitlab.com#/g/p/-/merge_requests/5" ,
40+ "https://gitlab.com/t3code/-/merge_requests/12" ,
41+ "https://gitlab.com/g//-/merge_requests/5" ,
42+ ] ) {
43+ expect ( definition . isChangeRequestReference ( url ) , url ) . toBe ( false ) ;
44+ expect ( parse ( url ) , url ) . toBeNull ( ) ;
45+ }
46+ for ( const url of [
47+ "https://code.acme.test/a/b/c/-/merge_requests/7?tab=diffs" ,
48+ "http://git.internal/a/b/c/-/merge_requests/7#note_1" ,
49+ "https://code.acme.test/a/b/c/-/merge_requests/7/diffs" ,
50+ ] ) {
51+ expect ( definition . isChangeRequestReference ( url ) , url ) . toBe ( true ) ;
52+ expect ( parse ( url ) , url ) . toMatchObject ( { repository : "a/b/c" , number : 7 } ) ;
53+ }
54+ } ) ;
55+
3456 it ( "builds merge request URLs below the repository" , ( ) => {
3557 expect (
3658 definition . changeRequestUrl ( {
0 commit comments