+16
-13
src/components/search.tsx
+16
-13
src/components/search.tsx
···
2
2
import { A, useLocation, useNavigate } from "@solidjs/router";
3
3
import { createResource, createSignal, For, onCleanup, onMount, Show } from "solid-js";
4
4
import { isTouchDevice } from "../layout";
5
+
import { BskyClient, bskyClients } from "../utils/bsky-clients";
5
6
import { createDebouncedValue } from "../utils/hooks/debounced";
6
7
7
8
export const [showSearch, setShowSearch] = createSignal(false);
···
68
69
setShowSearch(false);
69
70
if (input === "me" && localStorage.getItem("lastSignedIn") !== null) {
70
71
navigate(`/at://${localStorage.getItem("lastSignedIn")}`);
71
-
} else if (
72
-
!input.startsWith("https://bsky.app/") &&
73
-
(input.startsWith("https://") || input.startsWith("http://"))
74
-
) {
75
-
navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`);
76
72
} else if (search()?.length) {
77
73
navigate(`/at://${search()![0].did}`);
74
+
} else if (input.startsWith("https://") || input.startsWith("http://")) {
75
+
const host = input.slice(0, input.indexOf("/profile/", 8)) as BskyClient;
76
+
if (!bskyClients.has(host)) {
77
+
navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`);
78
+
} else {
79
+
const uri = input
80
+
.replace("at://", "")
81
+
.replace(`${host}/profile/`, "")
82
+
.replace("/post/", "/app.bsky.feed.post/");
83
+
const uriParts = uri.split("/");
84
+
navigate(
85
+
`/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`,
86
+
);
87
+
}
78
88
} else {
79
-
const uri = input
80
-
.replace("at://", "")
81
-
.replace("https://bsky.app/profile/", "")
82
-
.replace("/post/", "/app.bsky.feed.post/");
83
-
const uriParts = uri.split("/");
84
-
navigate(
85
-
`/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`,
86
-
);
89
+
navigate(`/${input}`);
87
90
}
88
91
setShowSearch(false);
89
92
};
+14
src/utils/bsky-clients.ts
+14
src/utils/bsky-clients.ts
···
1
+
export type BskyClient = `${"http" | "https"}://${string}`;
2
+
type BskyClientSet = Set<BskyClient>;
3
+
4
+
export const bskyClients: BskyClientSet = new Set<BskyClient>([
5
+
"http://localhost:19006",
6
+
"https://blacksky.community",
7
+
"https://bsky.app",
8
+
"https://catsky.social",
9
+
"https://deer.aylac.top",
10
+
"https://deer-social-ayla.pages.dev",
11
+
"https://deer.social",
12
+
"https://main.bsky.dev",
13
+
"https://social.daniela.lol",
14
+
]);