Skip to content

Commit d85a836

Browse files
author
sw-yx
committed
fix widow
1 parent 0ac2410 commit d85a836

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/components/providers.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import React from "react"
22
import { useIdentityContext, SettingContext } from "../context"
33
import { Settings } from "react-netlify-identity"
44

5-
const isLocalhost =
6-
window !== undefined &&
7-
Boolean(
8-
window.location.hostname === "localhost" ||
9-
// [::1] is the IPv6 localhost address.
10-
window.location.hostname === "[::1]" ||
11-
// 127.0.0.1/8 is considered localhost for IPv4.
12-
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
13-
)
14-
155
export function Providers() {
166
const setting = React.useContext(SettingContext)
177
const hasProviders =
188
setting &&
199
setting.external &&
2010
Object.entries(setting.external).some(([k, v]) => ["github", "gitlab", "bitbucket", "google"].includes(k) && v)
2111
if (!hasProviders) return null
12+
let isLocalhost = false
13+
if (typeof window !== "undefined") {
14+
isLocalhost = Boolean(
15+
window.location.hostname === "localhost" ||
16+
// [::1] is the IPv6 localhost address.
17+
window.location.hostname === "[::1]" ||
18+
// 127.0.0.1/8 is considered localhost for IPv4.
19+
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
20+
)
21+
}
2222
return (
2323
<div className="providersGroup">
2424
{isLocalhost && (

0 commit comments

Comments
 (0)