Skip to content

Commit b0555b5

Browse files
CaerusKarujelbourn
authored andcommitted
fix(progress-bar): generate correct url on server (#12813)
1 parent 4f53e4f commit b0555b5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/progress-bar/progress-bar.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import {
1313
Input,
1414
Optional,
1515
ViewEncapsulation,
16-
InjectionToken
16+
InjectionToken,
17+
inject,
1718
} from '@angular/core';
1819
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
1920
import {CanColor, mixinColor} from '@angular/material/core';
21+
import {DOCUMENT} from '@angular/common';
2022

2123
// TODO(josephperrott): Benchpress tests.
2224
// TODO(josephperrott): Add ARIA attributes for progress bar "for".
@@ -49,7 +51,9 @@ export interface MatProgressBarLocation {
4951

5052
/** @docs-private */
5153
export function MAT_PROGRESS_BAR_LOCATION_FACTORY(): MatProgressBarLocation {
52-
return typeof window !== 'undefined' ? window.location : {pathname: ''};
54+
const _document = inject(DOCUMENT);
55+
const pathname = (_document && _document.location && _document.location.pathname) || '';
56+
return {pathname};
5357
}
5458

5559

0 commit comments

Comments
 (0)