+
+
+ Unable to load this profile
+
+
+ This may be a temporary problem. Please try again.
+
+
+
+)
+
const UserHero = ({ user }: { user: UserProfile }) => {
const subscriptions = useUserSubscriptionsQuery(user.id)
diff --git a/apps/ssr/client/query/users.ts b/apps/ssr/client/query/users.ts
index f351e4cb8..a3f0318cb 100644
--- a/apps/ssr/client/query/users.ts
+++ b/apps/ssr/client/query/users.ts
@@ -2,7 +2,7 @@ import { followClient } from "@client/lib/api-fetch"
import { getProviders } from "@client/lib/auth"
import { getHydrateData } from "@client/lib/helper"
import type { LoginHydrateData } from "@client/pages/(login)/login/metadata"
-import { isBizId, sortByAlphabet } from "@follow/utils/utils"
+import { sortByAlphabet } from "@follow/utils/utils"
import type {
InboxSubscriptionResponse,
ListSubscriptionResponse,
@@ -10,6 +10,8 @@ import type {
} from "@follow-app/client-sdk"
import { useQuery } from "@tanstack/react-query"
+import { getUserProfile } from "../../src/lib/user-profile-params"
+
type GetUserSubscriptionsResponse = (
SubscriptionWithFeed | ListSubscriptionResponse | InboxSubscriptionResponse
)[]
@@ -69,13 +71,7 @@ export const useUserSubscriptionsQuery = (userId: string | undefined) => {
}
export const fetchUser = async (handleOrId: string | undefined) => {
- const handle = isBizId(handleOrId || "")
- ? handleOrId
- : `${handleOrId}`.startsWith("@")
- ? `${handleOrId}`.slice(1)
- : handleOrId
-
- const res = await followClient.api.profiles.getProfile({ id: handleOrId, handle })
+ const res = await getUserProfile(followClient, handleOrId)
return res.data
}
diff --git a/apps/ssr/package.json b/apps/ssr/package.json
index 87ae4d16b..8628f10d9 100644
--- a/apps/ssr/package.json
+++ b/apps/ssr/package.json
@@ -10,6 +10,7 @@
"dev": "cross-env NODE_ENV=development tsx watch --include \"src/**/*.ts\" --exclude \"./*.ts\" --exclude \"./*.mjs\" index.ts",
"meta": "tsx helper/meta-map.ts --watch",
"start": "tsx index.ts",
+ "test": "vitest run --config vitest.config.ts",
"typecheck": "tsc --noEmit"
},
"dependencies": {
diff --git a/apps/ssr/src/lib/hydration-script.test.ts b/apps/ssr/src/lib/hydration-script.test.ts
new file mode 100644
index 000000000..a270043ef
--- /dev/null
+++ b/apps/ssr/src/lib/hydration-script.test.ts
@@ -0,0 +1,109 @@
+import { runInNewContext } from "node:vm"
+
+import { minify } from "html-minifier-terser"
+import { parseHTML } from "linkedom"
+import { describe, expect, it } from "vitest"
+
+import { createHydrationScript, injectHydrationScript } from "./hydration-script"
+
+describe("hydration script", () => {
+ it("keeps attacker-controlled keys and data inside a single script element", () => {
+ const key = `profile