Skip to content
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

fix: properly transform invalid identifiers #246

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Conversation

paoloricciuti
Copy link
Collaborator

@paoloricciuti paoloricciuti commented Dec 18, 2024

Alternative to #226 since that was created on a fork and apparently can't run actions 🤷🏼


This fix the transform to handle the case where the template name is an invalid identifier.

Before it was using camelCase (only for the Story actually so that was also a bug) but the problem with camelCase is that it can lead to the same name from different string. For example Modal && Trigger and Modal || Trigger have the same camelCase.

To fix this i used a small hash function (stolen from the svelte code base) so that if the template is not a valid identifier (which needs to be to be a Snippet) it convert it to something like template_skajsh (which we don't care too much except for stack traces).

I don't know if it's a solution that you like but it works.

@JReinhold JReinhold added bug Something isn't working patch Increment the patch version when merged next Related to the next version labels Dec 19, 2024
Copy link
Collaborator

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot. ❤️

@JReinhold JReinhold merged commit f96d9f9 into next Dec 19, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next Related to the next version patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants