0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
This commit is contained in:
Rich Harris 2019-01-30 11:14:01 -05:00
parent 722e1fd383
commit 0d2622da49

View File

@ -38,7 +38,13 @@ function get_name(filename) {
const parts = filename.split(/[\/\\]/);
if (/index\.\w+/.test(parts)) parts.pop();
const base = parts.pop().replace(/\..+/, "");
const base = parts.pop()
.replace(/\..+/, "")
.replace(/[^a-zA-Z_$0-9]+/g, '_')
.replace(/^_/, '')
.replace(/_$/, '')
.replace(/^(\d)/, '_$1');
return base[0].toUpperCase() + base.slice(1);
}