Skip to content

Commit

Permalink
fix: only strip paths that start with source path (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath authored and ahangarha committed Mar 28, 2024
1 parent f098242 commit e92c32f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/rules/__tests__/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,12 @@ describe('file', () => {
expect(file.generator.filename(pathData)).toEqual(
'static/images/[name]-[hash][ext][query]'
);

const pathData2 = {
filename: 'app/javascript/app/assets/image.svg',
};
expect(file.generator.filename(pathData2)).toEqual(
'static/app/assets/[name]-[hash][ext][query]'
);
});
})
2 changes: 1 addition & 1 deletion package/rules/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
const path = dirname(pathData.filename)
const stripPaths = [...additionalPaths, sourcePath]

const selectedStripPath = stripPaths.find((includePath) => path.includes(includePath))
const selectedStripPath = stripPaths.find((includePath) => path.startsWith(includePath))

const folders = path
.replace(`${selectedStripPath}`, '')
Expand Down

0 comments on commit e92c32f

Please sign in to comment.