Skip to content

Commit

Permalink
Fix normalization of collection asset folder path
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Dec 24, 2024
1 parent abb0005 commit f1474f4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/services/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,18 @@ siteConfig.subscribe((config) => {
mediaFolder.startsWith('/') || mediaFolder.startsWith(globalMediaFolder)
);

let publicPath = stripSlashes(
(publicFolder ?? mediaFolder).replace('{{public_folder}}', globalPublicFolder).trim(),
);

// Prefix the public path with `/` unless it’s empty or starting with `.` (entry-relative
// setting) or starting with `@` (framework-specific)
publicPath = publicPath === '' || publicPath.match(/^[.@]/) ? publicPath : `/${publicPath}`;

return {
collectionName,
internalPath: stripSlashes(entryRelative ? (collectionFolder ?? '') : mediaFolder),
publicPath: `/${stripSlashes(
(publicFolder ?? mediaFolder).replace('{{public_folder}}', globalPublicFolder),
)}`,
publicPath,
entryRelative,
};
})
Expand Down

0 comments on commit f1474f4

Please sign in to comment.