@@ -16,6 +16,14 @@ const shouldLogContentIssues = process.env.NODE_ENV !== 'test';
1616const slugToFolderCache = new Map < string , string > ( ) ;
1717let cachedSortedFeedData : FeedData [ ] | null = null ;
1818
19+ function normalizeSlug ( slug : string ) : string {
20+ try {
21+ return decodeURIComponent ( slug ) ;
22+ } catch {
23+ return slug ;
24+ }
25+ }
26+
1927function logContentIssue ( message : string ) : void {
2028 if ( ! shouldLogContentIssues ) {
2129 return ;
@@ -252,15 +260,17 @@ function loadMetadata(folderPath: string): FeedFrontmatter | null {
252260
253261// Get folder path from slug (using cache or scanning)
254262export function getFolderSlug ( slug : string ) : string | null {
263+ const normalizedSlug = normalizeSlug ( slug ) ;
264+
255265 // Check cache first
256- if ( slugToFolderCache . has ( slug ) ) {
257- return slugToFolderCache . get ( slug ) ! ;
266+ if ( slugToFolderCache . has ( normalizedSlug ) ) {
267+ return slugToFolderCache . get ( normalizedSlug ) ! ;
258268 }
259269
260270 // Populate slug cache by loading full feed index first
261271 getSortedFeedData ( { includePrivate : true } ) ;
262- if ( slugToFolderCache . has ( slug ) ) {
263- return slugToFolderCache . get ( slug ) ! ;
272+ if ( slugToFolderCache . has ( normalizedSlug ) ) {
273+ return slugToFolderCache . get ( normalizedSlug ) ! ;
264274 }
265275
266276 if ( isProduction ) {
@@ -272,7 +282,7 @@ export function getFolderSlug(slug: string): string | null {
272282
273283 for ( const folderPath of allFolders ) {
274284 const metadata = loadMetadata ( folderPath ) ;
275- if ( metadata ?. slug === slug ) {
285+ if ( metadata ?. slug === normalizedSlug ) {
276286 return folderPath ;
277287 }
278288 }
0 commit comments