@@ -57,6 +57,11 @@ export class CarouselComponent implements OnInit {
5757 */
5858 description : string ;
5959
60+ /**
61+ * Current url
62+ */
63+ currentURL : string ;
64+
6065 /**
6166 * Auto slider paused
6267 */
@@ -92,6 +97,7 @@ export class CarouselComponent implements OnInit {
9297 this . link = this . carouselOptions . link ;
9398 this . description = this . carouselOptions . description ;
9499 this . bundle = this . carouselOptions . bundle ?? 'ORIGINAL' ;
100+ this . currentURL = this . _window . nativeWindow . location . origin ;
95101
96102 this . findAllBitstreamImages ( ) . subscribe ( ( res ) => {
97103 this . itemToImageHrefMap$ . next ( res ) ;
@@ -158,29 +164,16 @@ export class CarouselComponent implements OnInit {
158164 }
159165
160166 isLinkInternal ( link : string ) {
161- const currentURL = window . location . origin ;
162-
163- if ( link . startsWith ( '/' ) ) {
164- return true ;
165- }
166-
167- if ( link . startsWith ( currentURL ) ) {
168- link = link . substring ( currentURL . length ) ;
169- return link . startsWith ( '/' ) ;
170- }
171-
172- return false ;
167+ return link . startsWith ( '/' ) || link . startsWith ( this . currentURL ) ;
173168 }
174169
175- transformInternalLink ( link : string ) : string {
176- const currentURL = window . location . origin ;
177-
178- if ( link . startsWith ( currentURL ) ) {
179- link = link . substring ( currentURL . length ) ;
180- return link . startsWith ( '/' ) ? link : `/ ${ link } ` ;
170+ transformInternalLink ( link : string ) {
171+ if ( link . startsWith ( this . currentURL ) ) {
172+ const currentSegments = link . substring ( this . currentURL . length ) ;
173+ return currentSegments . startsWith ( '/' ) ? currentSegments : `/ ${ currentSegments } ` ;
174+ } else {
175+ return link ;
181176 }
182-
183- return link ;
184177 }
185178
186179 /**
0 commit comments