Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use window.location directly instead of parsing into URL #42888

Merged
merged 1 commit into from Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/next/client/components/app-router.tsx
Expand Up @@ -136,7 +136,8 @@ function Router({
// location.href is read as the initial value for canonicalUrl in the browser
// This is safe to do as canonicalUrl can't be rendered, it's only used to control the history updates in the useEffect further down in this file.
typeof window !== 'undefined'
? createHrefFromUrl(new URL(window.location.href))
? // window.location does not have the same type as URL but has all the fields createHrefFromUrl needs.
createHrefFromUrl(window.location as unknown as URL)
: initialCanonicalUrl,
}
}, [children, initialCanonicalUrl, initialTree])
Expand Down