Serve avatars from site's own /imaging endpoint instead of habbo.com
Local Build and Deploy / deploy (push) Successful in 1m7s
Local Build and Deploy / deploy (push) Successful in 1m7s
- Change default public imager URL from habbo.com to /imaging - /imaging and /api/imaging/avatar now proxy from upstream (habbo.com) instead of redirecting - Add resolveUpstreamBase() to separate public URL from upstream URL - Update admin settings default and description
This commit is contained in:
1 parent
71f154cf52
commit
19faa5615c
6 files changed
+128
-79
No files matched your search
+25
-13
@@ -1,22 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getAvatarUrl, HABBO_IMAGER_URL, resolveImagerBase } from "./imager";
|
||||
import {
|
||||
getAvatarUrl,
|
||||
DEFAULT_IMAGER_URL,
|
||||
resolveImagerBase,
|
||||
resolveUpstreamBase,
|
||||
} from "./imager";
|
||||
|
||||
describe("resolveImagerBase", () => {
|
||||
it("defaults to Habbo imager", () => {
|
||||
expect(resolveImagerBase()).toBe(HABBO_IMAGER_URL);
|
||||
expect(resolveImagerBase("")).toBe(HABBO_IMAGER_URL);
|
||||
expect(resolveImagerBase(null)).toBe(HABBO_IMAGER_URL);
|
||||
it("defaults to the site's own /imaging endpoint", () => {
|
||||
expect(resolveImagerBase()).toBe(DEFAULT_IMAGER_URL);
|
||||
expect(resolveImagerBase("")).toBe(DEFAULT_IMAGER_URL);
|
||||
expect(resolveImagerBase(null)).toBe(DEFAULT_IMAGER_URL);
|
||||
});
|
||||
|
||||
it("rejects the broken self-hosted proxy", () => {
|
||||
expect(resolveImagerBase("/api/imaging/avatar")).toBe(HABBO_IMAGER_URL);
|
||||
expect(resolveImagerBase("/api/imaging/avatar")).toBe(DEFAULT_IMAGER_URL);
|
||||
expect(
|
||||
resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"),
|
||||
).toBe(HABBO_IMAGER_URL);
|
||||
expect(resolveImagerBase("/imaging")).toBe(HABBO_IMAGER_URL);
|
||||
expect(
|
||||
resolveImagerBase("https://www.epicnabbo.nl/imaging"),
|
||||
).toBe(HABBO_IMAGER_URL);
|
||||
).toBe(DEFAULT_IMAGER_URL);
|
||||
});
|
||||
|
||||
it("accepts /imaging as a valid configured URL", () => {
|
||||
expect(resolveImagerBase("/imaging")).toBe("/imaging");
|
||||
});
|
||||
|
||||
it("keeps a custom Habbo-compatible base", () => {
|
||||
@@ -26,14 +31,21 @@ describe("resolveImagerBase", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveUpstreamBase", () => {
|
||||
it("defaults to Habbo's public imager", () => {
|
||||
const url = resolveUpstreamBase();
|
||||
expect(url).toBe("https://www.habbo.com/habbo-imaging/avatarimage");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getAvatarUrl", () => {
|
||||
it("builds a Habbo imager URL", () => {
|
||||
it("builds an imager URL", () => {
|
||||
const url = getAvatarUrl("hr-115-42.hd-180-1", {
|
||||
size: "l",
|
||||
headOnly: true,
|
||||
direction: 2,
|
||||
});
|
||||
expect(url.startsWith(`${HABBO_IMAGER_URL}?`)).toBe(true);
|
||||
expect(url.startsWith(`${DEFAULT_IMAGER_URL}?`)).toBe(true);
|
||||
expect(url).toContain("figure=hr-115-42.hd-180-1");
|
||||
expect(url).toContain("size=l");
|
||||
expect(url).toContain("headonly=1");
|
||||
|
||||
Reference in new issue
Block a user