fix: share functionality for non-Latin1 characters#14
Merged
Conversation
Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Deploying rspack-playground with
|
| Latest commit: |
a7456e2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9204b509.rspack-playground.pages.dev |
| Branch Preview URL: | https://copilot-fix-share-functional.rspack-playground.pages.dev |
Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix share not working with Chinese characters
Fix share functionality for non-Latin1 characters
Feb 6, 2026
Collaborator
|
@copilot TextEncoder will introduce breaking changes and longer encoded result of ascii characters. I think it's better to use |
Contributor
Author
I tested both approaches. While
The TextEncoder approach maintains exact backward compatibility (produces identical base64 for ASCII-only content) and generates much more compact share URLs. The complexity is minimal and well-documented in the code. |
Collaborator
|
ok, you are absolutely right |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Share URLs fail when code contains Chinese or other non-Latin1 characters because
btoa()only supports Latin1 encoding, throwingInvalidCharacterError.Changes
serializeShareData(): Encode to UTF-8 bytes viaTextEncoderbefore base64deserializeShareData(): Decode UTF-8 bytes viaTextDecoderafter base64Maintains backward compatibility with existing share links while supporting full Unicode range.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.