-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_name crashes on file named [...parts].svelte #2843
Comments
Also, I think
|
I also noticed inconsistency in preparing
Meaning the suggestion above (removing last file extension) will work inconsistently if de-indexing code is not updated to append the extension, something like: if (parts.length > 1) {
const indexMatch = parts[parts.length - 1].match(/^index(\.\w+)/)
if (indexMatch) {
parts.pop();
parts[parts.length - 1] += indexMatch[1]
}
} |
If there's a file named
[...parts].svelte
(syntax used by Sapper), it wouldn't compile becauseget_name(filename)
would crash:svelte/src/compile/index.ts
Lines 58 to 74 in d548a5a
The sequence of
.replace(...)
leads to the empty string, and thenbase[0].toUpperCase()
crashes withCannot read property 'toUpperCase' of undefined
.Related Sapper issue: sveltejs/sapper#709
Of course this particular problem can be fixed by prepending the chain of replacements with something like
.replace(/\.{2,}/g, "")
but perhaps it needs a more generic fix as well? Like if the replacements lead to the empty string, generate the component name with something likeComponent_${hash(lastPart))}
?The text was updated successfully, but these errors were encountered: