···11import { ROOT_DOMAIN } from "../utils.ts";
22-import index from "../www/index.html#denoRawImport=text.ts" with { type: "text" };
22+import index from "../www/index.html" with { type: "text" };
33import ascii from "./ascii.txt" with { type: "text" };
4455function route(
+20-17
server/src/routes/user.ts
···66} from "@atcute/identity-resolver";
77import { and, eq } from "drizzle-orm";
88import { routes } from "../db/schema.ts";
99-import { ROOT_DOMAIN, type db } from "../utils.ts";
99+import { type db, ROOT_DOMAIN } from "../utils.ts";
1010import ascii from "./ascii.txt" with { type: "text" };
11111212const handleResolver = new CompositeHandleResolver({
···2424 req: Request,
2525 user:
2626 | { handle: `${string}.${string}` }
2727- | { did: `did:plc:${string}` | `did:web:${string}` }
2727+ | { did: `did:plc:${string}` | `did:web:${string}` },
2828): Promise<Response> {
2929 // if handle: resolve did
3030 let did: `did:${"plc" | "web"}:${string}`;
···4141 {
4242 status: 500,
4343 statusText: "Internal Server Error",
4444- }
4444+ },
4545 );
4646 }
4747 } else did = user.did;
48484949 // look up in db
5050- const db_res =
5151- (
5252- await db
5353- .select()
5454- .from(routes)
5555- .where(
5656- and(
5757- eq(routes.did, did),
5858- eq(routes.url_route, new URL(req.url).pathname)
5959- )
6060- )
6161- ).at(0) ??
5050+ const db_res = (
5151+ await db
5252+ .select()
5353+ .from(routes)
5454+ .where(
5555+ and(
5656+ eq(routes.did, did),
5757+ eq(routes.url_route, new URL(req.url).pathname),
5858+ ),
5959+ )
6060+ ).at(0) ??
6261 (
6362 await db
6463 .select()
···7271404: The user has no atcities site or is missing a 404 page.
73727473If you're the owner of this account, head to https://atcities.dev/ for more information.
7575-The index of this account is at https://${"handle" in user ? user.handle : user.did.split(":").at(-1) + ".did-" + user.did.split(":").at(1)}.${ROOT_DOMAIN}/
7474+The index of this account is at https://${
7575+ "handle" in user
7676+ ? user.handle
7777+ : user.did.split(":").at(-1) + ".did-" + user.did.split(":").at(1)
7878+ }.${ROOT_DOMAIN}/
7679`);
7780 }
7881 try {
7982 const file = await Deno.readFile(
8080- `./blobs/${db_res.did}/${db_res.blob_cid}`
8383+ `./blobs/${db_res.did}/${db_res.blob_cid}`,
8184 );
8285 return new Response(file, {
8386 headers: {
+2-1
server/src/utils.ts
···5858 */
5959export function urlToRkey(url: string): string | undefined {
6060 // contains 0-9A-Za-z + special valid chars and / seperator. also can contain %XX with XX being hex
6161- if (!url.match(/^([a-zA-Z0-9/\-._~!$&'()*+,;=:@]|(%[0-9a-fA-F]{2}))*$/gm))
6161+ if (!url.match(/^([a-zA-Z0-9/\-._~!$&'()*+,;=:@]|(%[0-9a-fA-F]{2}))*$/gm)) {
6262 return;
6363+ }
6364 return (
6465 url
6566 // : replace is hoisted so it doesnt replace colons from elsewhere