mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
sanitize
This commit is contained in:
parent
722e1fd383
commit
0d2622da49
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user