Skip to content

Commit

Permalink
Improve nameWithoutHash function
Browse files Browse the repository at this point in the history
  • Loading branch information
andychow326 committed Sep 6, 2024
1 parent c28b3dc commit 94d8b45
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions authui/packages/vite-plugin-authgear-authui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ function removeLeadingSlash(s) {
* @return {string}
*/
function nameWithoutHash(filePath) {
const textArray = filePath.split(".");
if (textArray.length === 3) {
return textArray[0] + "." + textArray[2];
}
return filePath;
// The hash is placed between the base name and the extension
// e.g. abc.[hash].js or abc.def.[hash].css
return filePath.replace(/\.[0-9a-z]{8}\./, ".");
}

/**
Expand Down

0 comments on commit 94d8b45

Please sign in to comment.