Skip to content

Commit

Permalink
Merge pull request #2932 from Hongarc/parsing
Browse files Browse the repository at this point in the history
refactor: better parsing name of file
  • Loading branch information
Rich-Harris authored Jun 2, 2019
2 parents eb4e5e0 + 08f2ca6 commit 7b6cd52
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions register.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function deregisterExtension(extension) {

function registerExtension(extension) {
require.extensions[extension] = function(module, filename) {
const name = path.basename(filename)
.slice(0, -path.extname(filename).length)
const name = path.parse(filename).name
.replace(/^\d/, '_$&')
.replace(/[^a-zA-Z0-9_$]/g, '');

Expand All @@ -46,4 +45,4 @@ function registerExtension(extension) {
registerExtension('.svelte');
registerExtension('.html');

module.exports = register;
module.exports = register;

0 comments on commit 7b6cd52

Please sign in to comment.