From 329eced301fb4915bba98454ca725faeef50e0c3 Mon Sep 17 00:00:00 2001 From: ayla Date: Fri, 3 Oct 2025 14:50:20 -0300 Subject: [PATCH] support more bsky clients than just bsky.app --- src/components/search.tsx | 29 ++++++++++++++++------------- src/utils/bsky-clients.ts | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 src/utils/bsky-clients.ts diff --git a/src/components/search.tsx b/src/components/search.tsx index 6254f60..5148981 100644 --- a/src/components/search.tsx +++ b/src/components/search.tsx @@ -2,6 +2,7 @@ import { Client, CredentialManager } from "@atcute/client"; import { A, useLocation, useNavigate } from "@solidjs/router"; import { createResource, createSignal, For, onCleanup, onMount, Show } from "solid-js"; import { isTouchDevice } from "../layout"; +import { BskyClient, bskyClients } from "../utils/bsky-clients"; import { createDebouncedValue } from "../utils/hooks/debounced"; export const [showSearch, setShowSearch] = createSignal(false); @@ -68,22 +69,24 @@ const Search = () => { setShowSearch(false); if (input === "me" && localStorage.getItem("lastSignedIn") !== null) { navigate(`/at://${localStorage.getItem("lastSignedIn")}`); - } else if ( - !input.startsWith("https://bsky.app/") && - (input.startsWith("https://") || input.startsWith("http://")) - ) { - navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`); } else if (search()?.length) { navigate(`/at://${search()![0].did}`); + } else if (input.startsWith("https://") || input.startsWith("http://")) { + const host = input.slice(0, input.indexOf("/profile/", 8)) as BskyClient; + if (!bskyClients.has(host)) { + navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`); + } else { + const uri = input + .replace("at://", "") + .replace(`${host}/profile/`, "") + .replace("/post/", "/app.bsky.feed.post/"); + const uriParts = uri.split("/"); + navigate( + `/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`, + ); + } } else { - const uri = input - .replace("at://", "") - .replace("https://bsky.app/profile/", "") - .replace("/post/", "/app.bsky.feed.post/"); - const uriParts = uri.split("/"); - navigate( - `/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`, - ); + navigate(`/${input}`); } setShowSearch(false); }; diff --git a/src/utils/bsky-clients.ts b/src/utils/bsky-clients.ts new file mode 100644 index 0000000..810780e --- /dev/null +++ b/src/utils/bsky-clients.ts @@ -0,0 +1,14 @@ +export type BskyClient = `${"http" | "https"}://${string}`; +type BskyClientSet = Set; + +export const bskyClients: BskyClientSet = new Set([ + "http://localhost:19006", + "https://blacksky.community", + "https://bsky.app", + "https://catsky.social", + "https://deer.aylac.top", + "https://deer-social-ayla.pages.dev", + "https://deer.social", + "https://main.bsky.dev", + "https://social.daniela.lol", +]); -- 2.43.0