diff --git a/src/app.jsx b/src/app.jsx
index 86cfb728..ae24e8ce 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -19,6 +19,7 @@ import { useSnapshot } from 'valtio';
import AccountSheet from './components/account-sheet';
import Compose from './components/compose';
import Drafts from './components/drafts';
+import Link from './components/link';
import Loader from './components/loader';
import MediaModal from './components/media-modal';
import Modal from './components/modal';
@@ -52,6 +53,7 @@ import {
initPreferences,
} from './utils/api';
import { getAccessToken } from './utils/auth';
+import getInstanceStatusURL from './utils/get-instance-status-url';
import showToast from './utils/show-toast';
import states, { getStatus, saveStatus } from './utils/states';
import store from './utils/store';
@@ -189,6 +191,10 @@ function App() {
location,
});
+ if (/\/https?:/.test(location.pathname)) {
+ return ;
+ }
+
const nonRootLocation = useMemo(() => {
const { pathname } = location;
return !/^\/(login|welcome)/.test(pathname);
@@ -485,4 +491,28 @@ function BackgroundService({ isLoggedIn }) {
return null;
}
+function HttpRoute() {
+ const location = useLocation();
+ const url = location.pathname.replace(/^\//, '');
+ const statusURL = getInstanceStatusURL(url);
+ if (statusURL) {
+ window.location.hash = statusURL + '?view=full';
+ return null;
+ }
+ return (
+
+
Unable to process URL
+
+
+ {url}
+
+
+
+
+ Go home
+
+
+ );
+}
+
export { App };
diff --git a/src/pages/status.jsx b/src/pages/status.jsx
index 314fc3ff..9c0f3922 100644
--- a/src/pages/status.jsx
+++ b/src/pages/status.jsx
@@ -38,6 +38,8 @@ import { getCurrentAccount } from '../utils/store-utils';
import useScroll from '../utils/useScroll';
import useTitle from '../utils/useTitle';
+import getInstanceStatusURL from './../utils/get-instance-status-url';
+
const LIMIT = 40;
const THREAD_LIMIT = 20;
@@ -1091,19 +1093,4 @@ function SubComments({
);
}
-const statusRegex = /\/@([^@\/]+)@?([^\/]+)?\/([^\/]+)\/?$/i;
-const statusNoteRegex = /\/notes\/([^\/]+)\/?$/i;
-function getInstanceStatusURL(url) {
- // Regex /:username/:id, where username = @username or @username@domain, id = anything
- const { hostname, pathname } = new URL(url);
- const [, username, domain, id] = pathname.match(statusRegex) || [];
- if (id) {
- return `/${hostname}/s/${id}`;
- }
- const [, noteId] = pathname.match(statusNoteRegex) || [];
- if (noteId) {
- return `/${hostname}/s/${noteId}`;
- }
-}
-
export default StatusPage;
diff --git a/src/utils/get-instance-status-url.js b/src/utils/get-instance-status-url.js
new file mode 100644
index 00000000..28c810ff
--- /dev/null
+++ b/src/utils/get-instance-status-url.js
@@ -0,0 +1,19 @@
+export const statusRegex = /\/@([^@\/]+)@?([^\/]+)?\/([^\/]+)\/?$/i;
+export const statusNoteRegex = /\/notes\/([^\/]+)\/?$/i;
+function getInstanceStatusURL(url) {
+ // Regex /:username/:id, where username = @username or @username@domain, id = anything
+ const { hostname, pathname } = new URL(url);
+ const [, username, domain, id] = pathname.match(statusRegex) || [];
+
+ if (id) {
+ return `/${hostname}/s/${id}`;
+ }
+
+ const [, noteId] = pathname.match(statusNoteRegex) || [];
+
+ if (noteId) {
+ return `/${hostname}/s/${noteId}`;
+ }
+}
+
+export default getInstanceStatusURL;