Skip to content

Commit 1d17f0d

Browse files
committed
Handle root publicPath when resolving assets
Close #668
1 parent eabf3be commit 1d17f0d

2 files changed

Lines changed: 183 additions & 2 deletions

File tree

src/lib/services/assets/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,12 @@ export const getAssetByAbsolutePath = ({ path, entry, collectionName, fileName }
252252
}
253253

254254
// Handle assets stored in a subfolder of the internal path
255-
if (publicPath && internalPath && dirName && dirName.startsWith(`${publicPath}/`)) {
256-
internalPath = dirName.replace(publicPath, internalPath);
255+
if (publicPath && internalPath && dirName) {
256+
if (publicPath === '/') {
257+
internalPath = `${internalPath}${dirName}`;
258+
} else if (dirName.startsWith(`${publicPath}/`)) {
259+
internalPath = dirName.replace(publicPath, internalPath);
260+
}
257261
}
258262

259263
const fullPath = createPath([internalPath, baseName]);

src/lib/services/assets/index.test.js

Lines changed: 177 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)