Skip to content

Commit 8fc367d

Browse files
committed
More SSR improvements
1 parent 7a0a008 commit 8fc367d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

react/src/ModalRoot.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ export const ModalRoot = ({ children }) => {
565565
console.error('No base url in modal response data so cannot navigate back')
566566
return
567567
}
568-
if (!isNavigating && window.location.href !== modalOnBase.baseUrl) {
568+
if (!isNavigating && typeof window !== 'undefined' && window.location.href !== modalOnBase.baseUrl) {
569569
router.visit(modalOnBase.baseUrl, {
570570
preserveScroll: true,
571571
preserveState: true,

vue/src/ModalRoot.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ onUnmounted(
3636
return
3737
}
3838
39-
if (!isNavigating && window.location.href !== modalOnBase.baseUrl) {
39+
if (!isNavigating && typeof window !== 'undefined' && window.location.href !== modalOnBase.baseUrl) {
4040
router.visit(modalOnBase.baseUrl, {
4141
preserveScroll: true,
4242
preserveState: true,

vue/src/helpers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ function generateIdUsing(callback) {
55
}
66

77
function sameUrlPath(url1, url2) {
8-
url1 = typeof url1 === 'string' ? new URL(url1, window.location.origin) : url1
9-
url2 = typeof url2 === 'string' ? new URL(url2, window.location.origin) : url2
8+
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost'
9+
url1 = typeof url1 === 'string' ? new URL(url1, origin) : url1
10+
url2 = typeof url2 === 'string' ? new URL(url2, origin) : url2
1011

1112
return `${url1.origin}${url1.pathname}` === `${url2.origin}${url2.pathname}`
1213
}

0 commit comments

Comments
 (0)