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' ,
@@ -391,20 +395,22 @@ export class RepositoryService {
391395 return 0 ;
392396 }
393397
394- // Find the link with rel="last"
395- const lastLinkPattern = / < ( [ ^ > ] + ?) > ; r e l = " l a s t " / ;
396- const lastLinkMatch = linkHeader . match ( lastLinkPattern ) ;
398+ // Split the linkHeader by commas to separate individual links
399+ const links = linkHeader . split ( ',' ) ;
400+
401+ // Find the last link in the header
402+ const lastLink = links
403+ . find ( ( link ) => link . includes ( 'rel="last"' ) )
404+ ?. split ( ';' ) [ 0 ]
405+ ?. trim ( )
406+ . slice ( 1 , - 1 ) ;
397407
398- if ( ! lastLinkMatch ) {
408+ if ( ! lastLink ) {
399409 return 0 ;
400410 }
401411
402- const lastLink = lastLinkMatch [ 1 ] ;
403-
404- // Parse as a URL
405412 const url = new URL ( lastLink ) ;
406413
407- // Extract query parameters
408414 const queryParams = new URLSearchParams ( url . search ) ;
409415 const page = parseInt ( queryParams . get ( 'page' ) || '' , 10 ) ;
410416
You can’t perform that action at this time.
0 commit comments