mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 02:43:24 +00:00
Fix: Replace Buffer with atob for Cloudflare Workers
Buffer is not available in Workers environment. Use atob() for base64 decoding which works in both Node.js and Workers. Fixes ReferenceError: Buffer is not defined 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10
src/bloom.ts
10
src/bloom.ts
@@ -12,9 +12,13 @@ export class BloomFilter {
|
||||
* Creates a bloom filter from a base64 encoded bit array
|
||||
*/
|
||||
constructor(base64Data: string, numHashes: number = 3) {
|
||||
// Decode base64 to buffer
|
||||
const buffer = Buffer.from(base64Data, 'base64');
|
||||
this.bits = new Uint8Array(buffer);
|
||||
// Decode base64 to Uint8Array (works in both Node.js and Workers)
|
||||
const binaryString = atob(base64Data);
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
this.bits = bytes;
|
||||
this.size = this.bits.length * 8;
|
||||
this.numHashes = numHashes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user