-
-
Notifications
You must be signed in to change notification settings - Fork 73
fix(adapter): sanitize wrangler project name for Cloudflare compatibility #861
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
base: main
Are you sure you want to change the base?
fix(adapter): sanitize wrangler project name for Cloudflare compatibility #861
Conversation
🦋 Changeset detectedLatest commit: eab1fd8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical issue where Cloudflare Wrangler fails when project names contain dots, underscores, or other invalid characters. The solution adds a sanitization function that transforms project names from package.json to comply with Wrangler's strict naming requirements (alphanumeric lowercase with dashes only).
Key Changes:
- Introduced
sanitizeWranglerName()utility function that normalizes project names to Wrangler-compatible format - Applied sanitization to the Cloudflare adapter when generating
wrangler.jsoncconfiguration - Added comprehensive unit tests covering edge cases like dots, Unicode characters, length limits, and invalid inputs
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
packages/sv/lib/cli/add/utils.ts |
Adds the core sanitizeWranglerName() function that converts project names to lowercase, replaces invalid characters with dashes, enforces 63-char limit, and removes leading/trailing dashes |
packages/sv/lib/core/tests/wrangler.ts |
Comprehensive test suite covering basic sanitization, special characters, Unicode, length limits, and edge cases |
packages/sv/lib/addons/sveltekit-adapter/index.ts |
Integrates the sanitization function when setting the Wrangler project name from package.json |
packages/sv/lib/addons/_tests/sveltekit-adapter/test.ts |
Adds integration test assertions to verify generated wrangler.jsonc names are properly sanitized |
.changeset/sanitize-wrangler-name.md |
Documents the fix for release notes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
commit: |
jonasfroeller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right 😅
I don't know if it's me or your AI that is right >< |
fixes projects with dotted names and other naming conventions
see https://developers.cloudflare.com/workers/wrangler/configuration/#:~:text=assets%2Donly%20Workers.-,name,-string