Fixes lolllll
This commit is contained in:
parent
825e6ec5c7
commit
287e7e5660
|
|
@ -10,13 +10,13 @@ importers:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@cloudflare/workers-types':
|
'@cloudflare/workers-types':
|
||||||
specifier: ^4.20260617.1
|
specifier: ^4.20260617.1
|
||||||
version: 4.20260617.1
|
version: 4.20260625.1
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^6.0.3
|
specifier: ^6.0.3
|
||||||
version: 6.0.3
|
version: 6.0.3
|
||||||
wrangler:
|
wrangler:
|
||||||
specifier: ^4.105.0
|
specifier: ^4.105.0
|
||||||
version: 4.105.0(@cloudflare/workers-types@4.20260617.1)
|
version: 4.105.0(@cloudflare/workers-types@4.20260625.1)
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
|
@ -63,8 +63,8 @@ packages:
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@cloudflare/workers-types@4.20260617.1':
|
'@cloudflare/workers-types@4.20260625.1':
|
||||||
resolution: {integrity: sha512-HdbP3CNcdMZBwegitFDjWvzv+6wPkFXvV9gBXMnf6RjV2Cy3W8TJL3IhSEGul0S6F1DHjnucP7lrpIsvkzNEjA==}
|
resolution: {integrity: sha512-asH0RhPHiNu/IUSssyiOJYAcGqysy0DJpO9fihC6KATaayD9CE1E9bgNQozTLUraxrCT2qkM4CBOIcV0M5NPJw==}
|
||||||
|
|
||||||
'@cspotcode/source-map-support@0.8.1':
|
'@cspotcode/source-map-support@0.8.1':
|
||||||
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
|
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
|
||||||
|
|
@ -447,8 +447,8 @@ packages:
|
||||||
pathe@2.0.3:
|
pathe@2.0.3:
|
||||||
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
|
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
|
||||||
|
|
||||||
semver@7.8.4:
|
semver@7.8.5:
|
||||||
resolution: {integrity: sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==}
|
resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
|
@ -533,7 +533,7 @@ snapshots:
|
||||||
'@cloudflare/workerd-windows-64@1.20260625.1':
|
'@cloudflare/workerd-windows-64@1.20260625.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@cloudflare/workers-types@4.20260617.1': {}
|
'@cloudflare/workers-types@4.20260625.1': {}
|
||||||
|
|
||||||
'@cspotcode/source-map-support@0.8.1':
|
'@cspotcode/source-map-support@0.8.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
@ -801,13 +801,13 @@ snapshots:
|
||||||
|
|
||||||
pathe@2.0.3: {}
|
pathe@2.0.3: {}
|
||||||
|
|
||||||
semver@7.8.4: {}
|
semver@7.8.5: {}
|
||||||
|
|
||||||
sharp@0.34.5:
|
sharp@0.34.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@img/colour': 1.1.0
|
'@img/colour': 1.1.0
|
||||||
detect-libc: 2.1.2
|
detect-libc: 2.1.2
|
||||||
semver: 7.8.4
|
semver: 7.8.5
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-darwin-arm64': 0.34.5
|
'@img/sharp-darwin-arm64': 0.34.5
|
||||||
'@img/sharp-darwin-x64': 0.34.5
|
'@img/sharp-darwin-x64': 0.34.5
|
||||||
|
|
@ -855,7 +855,7 @@ snapshots:
|
||||||
'@cloudflare/workerd-linux-arm64': 1.20260625.1
|
'@cloudflare/workerd-linux-arm64': 1.20260625.1
|
||||||
'@cloudflare/workerd-windows-64': 1.20260625.1
|
'@cloudflare/workerd-windows-64': 1.20260625.1
|
||||||
|
|
||||||
wrangler@4.105.0(@cloudflare/workers-types@4.20260617.1):
|
wrangler@4.105.0(@cloudflare/workers-types@4.20260625.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@cloudflare/kv-asset-handler': 0.5.0
|
'@cloudflare/kv-asset-handler': 0.5.0
|
||||||
'@cloudflare/unenv-preset': 2.16.1(unenv@2.0.0-rc.24)(workerd@1.20260625.1)
|
'@cloudflare/unenv-preset': 2.16.1(unenv@2.0.0-rc.24)(workerd@1.20260625.1)
|
||||||
|
|
@ -866,7 +866,7 @@ snapshots:
|
||||||
unenv: 2.0.0-rc.24
|
unenv: 2.0.0-rc.24
|
||||||
workerd: 1.20260625.1
|
workerd: 1.20260625.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@cloudflare/workers-types': 4.20260617.1
|
'@cloudflare/workers-types': 4.20260625.1
|
||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- bufferutil
|
- bufferutil
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ allowBuilds:
|
||||||
sharp: true
|
sharp: true
|
||||||
workerd: true
|
workerd: true
|
||||||
minimumReleaseAgeExclude:
|
minimumReleaseAgeExclude:
|
||||||
- miniflare@4.20260625.1
|
- miniflare@4.20260625.0 || 4.20260625.1
|
||||||
- wrangler@4.105.0
|
- wrangler@4.105.0
|
||||||
|
|
@ -112,18 +112,43 @@ async function fetchClientBadges(id: string): Promise<UnifiedClientBadge[] | und
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deterministic id for a badge — the upstream API has no id field of its
|
* Host -> display-name table. The equicord endpoint aggregates several
|
||||||
|
* underlying services, and the only thing in the response that tells us
|
||||||
|
* which one a given badge actually came from is the hostname of its icon
|
||||||
|
* URL. Add new services here as we spot them in the wild — anything not
|
||||||
|
* listed falls back to "Equicord" (the aggregator's own native badges,
|
||||||
|
* e.g. /public/badges/equicord.png, live on that host too).
|
||||||
|
*
|
||||||
|
* Still TBD / not yet seen in a sample response: ReviewDB, Aero, Aliucord,
|
||||||
|
* Raincord, Velocity, Enmity, Replugged, Paicord.
|
||||||
|
*/
|
||||||
|
const SOURCE_BY_HOST: Record<string, string> = {
|
||||||
|
"gb.obamabot.me": "BadgeVault",
|
||||||
|
"nekocord.dev": "Neokcord",
|
||||||
|
"badges.vencord.dev": "Vencord",
|
||||||
|
"badges.equicord.org": "Equicord",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Falls back to "Equicord" for unknown/malformed hosts. */
|
||||||
|
function sourceForIconUrl(iconUrl: string): string {
|
||||||
|
try {
|
||||||
|
const host = new URL(iconUrl).hostname;
|
||||||
|
return SOURCE_BY_HOST[host] ?? "Equicord";
|
||||||
|
} catch {
|
||||||
|
return "Equicord";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Human-readable id for a badge — the upstream API has no id field of its
|
||||||
* own (these are arbitrary per-user badges, not a fixed catalog), so we
|
* own (these are arbitrary per-user badges, not a fixed catalog), so we
|
||||||
* derive a stable short hash from tooltip+icon_url. Same badge -> same id
|
* build one from the originating service + tooltip, e.g.
|
||||||
* every time, which is all that's needed for React keys / dedup / lookups.
|
* "GlobalBadges - Moffman" or "Equicord - Equicord Contributor".
|
||||||
|
*
|
||||||
|
* Note: this is NOT guaranteed unique — two badges from the same service
|
||||||
|
* with the same tooltip text collide. Fine for display/grouping; if exact
|
||||||
|
* per-badge identity is ever needed, icon_url is the only unique field.
|
||||||
*/
|
*/
|
||||||
function badgeId(tooltip: string, iconUrl: string): string {
|
function badgeId(tooltip: string, iconUrl: string): string {
|
||||||
const input = `${tooltip}\u0000${iconUrl}`;
|
return `${sourceForIconUrl(iconUrl)} - ${tooltip}`;
|
||||||
// FNV-1a 32-bit — fast, sync, good enough distribution for this purpose.
|
|
||||||
let hash = 0x811c9dc5;
|
|
||||||
for (let i = 0; i < input.length; i++) {
|
|
||||||
hash ^= input.charCodeAt(i);
|
|
||||||
hash = Math.imul(hash, 0x01000193);
|
|
||||||
}
|
|
||||||
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue