Skip to content

Commit

Permalink
Improve asset finder
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Oct 30, 2024
1 parent 996840e commit 742cd75
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/services/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ export const getAssetByPath = (savedPath, { entry, collection } = {}) => {
return assets.flat(1).filter(Boolean)[0] ?? undefined;
}

const exactMatch = get(allAssets).find((asset) => asset.path === stripSlashes(savedPath));

if (exactMatch) {
return exactMatch;
}

const { dirname: publicPath, basename: fileName } = getPathInfo(savedPath);

if (!publicPath) {
Expand Down

0 comments on commit 742cd75

Please sign in to comment.