A social knowledge tool for researchers built on ATProto
45
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add trailing slash only for bare root URLs without paths or parameters

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

+15 -2
+15 -2
src/modules/cards/domain/value-objects/URL.ts
··· 30 30 31 31 try { 32 32 // Validate URL format using the global URL constructor 33 - new globalThis.URL(trimmedUrl); 34 - return ok(new URL({ value: trimmedUrl })); 33 + const parsedUrl = new globalThis.URL(trimmedUrl); 34 + 35 + // Add trailing slash only to truly bare root URLs 36 + // (no path, no query parameters, no fragments) 37 + let normalizedUrl = trimmedUrl; 38 + if ( 39 + (parsedUrl.pathname === '' || parsedUrl.pathname === '/') && 40 + parsedUrl.search === '' && 41 + parsedUrl.hash === '' && 42 + !trimmedUrl.endsWith('/') 43 + ) { 44 + normalizedUrl = trimmedUrl + '/'; 45 + } 46 + 47 + return ok(new URL({ value: normalizedUrl })); 35 48 } catch (error) { 36 49 return err(new InvalidURLError('Invalid URL format')); 37 50 }