Skip to content

Commit d84ffbb

Browse files
committed
Enforce to redirect www subdomain
1 parent 34c03cd commit d84ffbb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

index.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@
2323
var language = languages[code];
2424
if (!language) { language = "en"; }
2525

26-
document.location = "/" + language + "/";
26+
// If we're running on localhost/loopback for local development,
27+
// keep redirects relative so the developer can test locally.
28+
var host = window.location.hostname;
29+
var isLocal = (host === 'localhost' || host === '127.0.0.1' || host === '::1');
30+
if (isLocal) {
31+
document.location = "/" + language + "/";
32+
} else {
33+
document.location = "https://www.ruby-lang.org/" + language + "/";
34+
}
2735
</script>
2836
<noscript>
29-
<meta http-equiv="refresh" content="0; url=/en/">
37+
<meta http-equiv="refresh" content="0; url=https://www.ruby-lang.org/en/">
3038
</noscript>
3139
</head>
3240
<body>
33-
<p><a href="/en/">Click here</a> to be redirected.</p>
41+
<p><a href="https://www.ruby-lang.org/en/">Click here</a> to be redirected.</p>
3442
</body>
3543
</html>

0 commit comments

Comments
 (0)