Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export default function Document() {
crossOrigin="anonymous"
/>
<link rel="stylesheet" href="/static/style.css" />
<script
dangerouslySetInnerHTML={{
__html: `
// Redirect from opencerts.io to www.opencerts.io while preserving hash
if (window.location.hostname === 'opencerts.io') {
window.location.replace('https://www.opencerts.io' + window.location.pathname + window.location.search + window.location.hash);
}
`,
}}
/>
</Head>
<body>
<Main />
Expand Down
8 changes: 0 additions & 8 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ const useUrlParamsThenScrubUrl = ({ enabled }: UseUrlParamsThenScrubUrlParam): U

useEffect(() => {
if (enabled) {
// Fix for non-www redirect losing hash fragment
// If we're on opencerts.io (without www), redirect to www.opencerts.io with hash preserved
if (typeof window !== "undefined" && window.location.hostname === "opencerts.io") {
const newUrl = `https://www.opencerts.io${window.location.pathname}${window.location.search}${window.location.hash}`;
window.location.replace(newUrl);
return;
}

setUrlParams((currUrlParams) => {
// once the fragment is set, we never update it again
if (currUrlParams !== undefined) {
Expand Down