1
Fork 0
mirror of https://github.com/diced/zipline.git synced 2025-04-11 23:31:17 -05:00

Update index.ts

randomize returnDomain if "x-zipline-domain" is a comma separated list

- Updated returnDomain handling to support both single and comma-separated domain strings.
- Implemented random selection from the list of domains.
This commit is contained in:
nobody 2025-02-19 16:27:41 +01:00 committed by GitHub
parent 7a93070958
commit 8adff1c789
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,7 +62,11 @@ export default fastifyPlugin(
);
let maxViews: number | undefined;
const returnDomain = req.headers['x-zipline-domain'];
let returnDomain = req.headers['x-zipline-domain'];
if (returnDomain) {
const domainArray = returnDomain.split(",");
returnDomain = domainArray[Math.floor(Math.random() * domainArray.length)].trim();
}
const maxViewsHeader = req.headers['x-zipline-max-views'];
if (maxViewsHeader) {