Skip to content

Commit 004387b

Browse files
committed
Fix reference Errors with SSR
1 parent 286696b commit 004387b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/app/core/services/internal-link.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Inject, Injectable } from '@angular/core';
22
import { NativeWindowRef, NativeWindowService } from './window.service';
3+
import { isEmpty } from '../../shared/empty.util';
34

45
/**
56
* LinkService provides utility functions for working with links, such as checking if a link is internal
@@ -22,6 +23,10 @@ export class InternalLinkService {
2223
* @returns A boolean indicating whether the link is internal.
2324
*/
2425
public isLinkInternal(link: string): boolean {
26+
if (isEmpty(this.currentURL)) {
27+
return false;
28+
}
29+
2530
// Create a Domain object for the provided link
2631
const currentDomain = new URL(this.currentURL).hostname;
2732

@@ -39,6 +44,9 @@ export class InternalLinkService {
3944
* @returns The relative path for the given internal link.
4045
*/
4146
public getRelativePath(link: string): string {
47+
if (isEmpty(this.currentURL)) {
48+
return link;
49+
}
4250
// Create a Domain object for the provided link
4351
const currentDomain = new URL(this.currentURL).hostname;
4452

0 commit comments

Comments
 (0)