Fork of atp.tools as a universal profile for people on the ATmosphere

Merge pull request #4 from Ovyerus/feat/at-handles-prefix

feat: allow searching by handles starting with `@`

authored by

natalie and committed by
GitHub
49f28655 6e98e1a8

+10 -8
+10 -8
src/components/smartSearchBar.tsx
··· 23 23 24 24 function isMobile() { 25 25 return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( 26 - navigator.userAgent, 26 + navigator.userAgent 27 27 ); 28 28 } 29 29 ··· 38 38 39 39 const handleSubmit = (e: React.FormEvent) => { 40 40 e.preventDefault(); 41 - if (input.trim()) { 41 + const value = input.trim(); 42 + if (value && value !== "@") { 42 43 // replace at:// with / to match the route correctly 43 - if (input.includes("bsky.app") || input.includes("main.bsky.dev")) { 44 + if (value.includes("bsky.app") || value.includes("main.bsky.dev")) { 44 45 try { 45 - const url = new URL(input); 46 + const url = new URL(value); 46 47 const pathParts = url.pathname.split("/"); 47 48 48 49 if (pathParts[1] === "profile") { ··· 68 69 } catch (e) { 69 70 console.error("Invalid Bluesky URL:", e); 70 71 } 71 - } else if (input.startsWith("pds/") || input.startsWith("https:/")) { 72 + } else if (value.startsWith("pds/") || value.startsWith("https:/")) { 72 73 navigate({ 73 74 to: "/pds/$url", 74 75 params: { 75 - url: input.replace("https:/", "").replace("pds/", ""), 76 + url: value.replace("https:/", "").replace("pds/", ""), 76 77 }, 77 78 }); 78 - } else if (input === "typing") { 79 + } else if (value === "typing") { 79 80 navigate({ to: "/rnfgrertt/typing" }); 80 81 } else { 82 + // Allow handle lookups to start with @ 81 83 navigate({ 82 - to: `/at:/${input.replace("at:/", "")}`, 84 + to: `/at:/${value.replace("at:/", "").replace(/^@/, "")}`, 83 85 }); 84 86 } 85 87 setOpen(false);