2023-08-08 12:29:04 +03:00
|
|
|
import { useLayoutEffect } from 'preact/hooks';
|
2023-04-17 14:00:41 +03:00
|
|
|
import { useLocation } from 'react-router-dom';
|
|
|
|
|
|
|
|
import Link from '../components/link';
|
|
|
|
import getInstanceStatusURL from '../utils/get-instance-status-url';
|
|
|
|
|
|
|
|
export default function HttpRoute() {
|
|
|
|
const location = useLocation();
|
|
|
|
const url = location.pathname.replace(/^\//, '');
|
|
|
|
const statusURL = getInstanceStatusURL(url);
|
2023-08-08 12:29:04 +03:00
|
|
|
|
|
|
|
useLayoutEffect(() => {
|
|
|
|
if (statusURL) {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location.hash = statusURL + '?view=full';
|
|
|
|
}, 300);
|
|
|
|
}
|
|
|
|
}, [statusURL]);
|
|
|
|
|
2023-04-17 14:00:41 +03:00
|
|
|
return (
|
|
|
|
<div class="ui-state" tabIndex="-1">
|
2023-08-08 12:29:04 +03:00
|
|
|
{statusURL ? (
|
|
|
|
<>
|
|
|
|
<h2>Redirecting…</h2>
|
|
|
|
<p>
|
|
|
|
<a href={`#${statusURL}?view=full`}>{statusURL}</a>
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<h2>Unable to process URL</h2>
|
|
|
|
<p>
|
2023-09-26 05:55:36 +03:00
|
|
|
<a href={url} target="_blank" rel="noopener noreferrer">
|
2023-08-08 12:29:04 +03:00
|
|
|
{url}
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
)}
|
2023-04-17 14:00:41 +03:00
|
|
|
<hr />
|
|
|
|
<p>
|
|
|
|
<Link to="/">Go home</Link>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|