File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11< ngb-carousel #carousel [interval] ="2000 " (slide) ="onSlide($event) " class ="ds-carousel ">
22 < ng-template ngbSlide *ngFor ="let item of items; let i = index; let last = last ">
33 < ng-container *ngIf ="getItemLink(item.indexableObject); let currentLink; else carouselContent ">
4- < a *ngIf ="isLinkInternal(currentLink) " [routerLink] ="currentLink ">
4+ < a *ngIf ="isLinkInternal(currentLink) " [routerLink] ="transformInternalLink( currentLink) ">
55 < ng-container *ngTemplateOutlet ="carouselContent "> </ ng-container >
66 </ a >
77 < a *ngIf ="!isLinkInternal(currentLink) " [href] ="currentLink " [target] ="carouselOptions.targetBlank ? '_blank' : null ">
Original file line number Diff line number Diff line change @@ -158,7 +158,29 @@ export class CarouselComponent implements OnInit {
158158 }
159159
160160 isLinkInternal ( link : string ) {
161- return link . startsWith ( '/' ) ;
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 ;
173+ }
174+
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 } ` ;
181+ }
182+
183+ return link ;
162184 }
163185
164186 /**
You can’t perform that action at this time.
0 commit comments