From 407e4ac80301c3a4abe58d3088d948fa031a7ee4 Mon Sep 17 00:00:00 2001 From: saltbo Date: Sat, 20 Jun 2026 10:53:30 -0400 Subject: [PATCH] refactor(s3): drop dead getPublicUrl gateway method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No callers remain after select('public') was removed in #456 — the public-bucket flow is gone, so the gateway method, its port declaration and its tests are dead code. Co-Authored-By: Claude Opus 4.8 (1M context) --- server/adapters/gateways/s3.test.ts | 21 --------------------- server/adapters/gateways/s3.ts | 7 ------- server/usecases/ports/s3.ts | 1 - 3 files changed, 29 deletions(-) diff --git a/server/adapters/gateways/s3.test.ts b/server/adapters/gateways/s3.test.ts index fa4e766e..d39c49c4 100644 --- a/server/adapters/gateways/s3.test.ts +++ b/server/adapters/gateways/s3.test.ts @@ -322,27 +322,6 @@ describe('S3Service', () => { }) }) - describe('getPublicUrl', () => { - it('uses customHost when available', () => { - const s = makeStorage({ customHost: 'https://cdn.example.com' }) - expect(service.getPublicUrl(s, 'a/b.jpg')).toBe('https://cdn.example.com/a/b.jpg') - }) - - it('strips trailing slash from customHost', () => { - const s = makeStorage({ customHost: 'https://cdn.example.com/' }) - expect(service.getPublicUrl(s, 'a/b.jpg')).toBe('https://cdn.example.com/a/b.jpg') - }) - - it('falls back to endpoint/bucket when no customHost', () => { - expect(service.getPublicUrl(storage, 'a/b.jpg')).toBe('https://s3.example.com/my-bucket/a/b.jpg') - }) - - it('strips trailing slash from endpoint', () => { - const s = makeStorage({ endpoint: 'https://s3.example.com/' }) - expect(service.getPublicUrl(s, 'a/b.jpg')).toBe('https://s3.example.com/my-bucket/a/b.jpg') - }) - }) - describe('headObject', () => { it('returns size, contentType, and the quote-stripped etag', async () => { mockSend.mockResolvedValueOnce({ diff --git a/server/adapters/gateways/s3.ts b/server/adapters/gateways/s3.ts index 1ed73bb0..0318cd16 100644 --- a/server/adapters/gateways/s3.ts +++ b/server/adapters/gateways/s3.ts @@ -196,13 +196,6 @@ export class S3Service implements S3Gateway { return parsed.toString() } - getPublicUrl(storage: S3StorageCredentials, key: string): string { - if (storage.customHost) { - return `${storage.customHost.replace(/\/$/, '')}/${key}` - } - return `${storage.endpoint.replace(/\/$/, '')}/${storage.bucket}/${key}` - } - async headObject( storage: S3StorageCredentials, key: string, diff --git a/server/usecases/ports/s3.ts b/server/usecases/ports/s3.ts index 3872d011..9279fe38 100644 --- a/server/usecases/ports/s3.ts +++ b/server/usecases/ports/s3.ts @@ -34,7 +34,6 @@ export interface S3Gateway { abortMultipartUpload(storage: S3StorageCredentials, key: string, uploadId: string): Promise presignDownload(storage: S3StorageCredentials, key: string, filename: string, expiresIn?: number): Promise presignInline(storage: S3StorageCredentials, key: string, mime: string, expiresIn?: number): Promise - getPublicUrl(storage: S3StorageCredentials, key: string): string // `etag` is the S3 ETag with surrounding quotes stripped (= content MD5 for a // single PutObject); used to verify a finalized single-PUT upload. headObject(storage: S3StorageCredentials, key: string): Promise<{ size: number; contentType: string; etag: string }>