File tree Expand file tree Collapse file tree
angular-ngrx-scss/src/app/repository/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ export class RepositoryService {
102102 url += `+sort:${ params . sort } ` ;
103103 }
104104
105+ if ( params ?. page ) {
106+ url += `&page=${ params . page } ` ;
107+ }
108+
105109 return this . http
106110 . get ( url , {
107111 observe : 'response' ,
@@ -387,20 +391,22 @@ export class RepositoryService {
387391 return 0 ;
388392 }
389393
390- // Find the link with rel="last"
391- const lastLinkPattern = / < ( [ ^ > ] + ?) > ; r e l = " l a s t " / ;
392- const lastLinkMatch = linkHeader . match ( lastLinkPattern ) ;
394+ // Split the linkHeader by commas to separate individual links
395+ const links = linkHeader . split ( ',' ) ;
393396
394- if ( ! lastLinkMatch ) {
397+ // Find the last link in the header
398+ const lastLink = links
399+ . find ( ( link ) => link . includes ( 'rel="last"' ) )
400+ ?. split ( ';' ) [ 0 ]
401+ ?. trim ( )
402+ . slice ( 1 , - 1 ) ;
403+
404+ if ( ! lastLink ) {
395405 return 0 ;
396406 }
397407
398- const lastLink = lastLinkMatch [ 1 ] ;
399-
400- // Parse as a URL
401408 const url = new URL ( lastLink ) ;
402409
403- // Extract query parameters
404410 const queryParams = new URLSearchParams ( url . search ) ;
405411 const page = parseInt ( queryParams . get ( 'page' ) || '' , 10 ) ;
406412
You can’t perform that action at this time.
0 commit comments