fix(envvars): fix split for pasting envvars with query params#1156
fix(envvars): fix split for pasting envvars with query params#1156waleedlatif1 merged 1 commit intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a critical bug in the environment variable paste handling functionality within the settings modal. The issue occurred when users pasted environment variables containing URLs with query parameters or other values with multiple = characters. The original implementation used split('=') which would incorrectly break these values into multiple parts, corrupting the data.
The fix introduces two key improvements:
- Smarter parsing logic: Replaces
split('=')withindexOf('=')to find only the first equals sign and treat everything after it as the complete value, preserving URLs and other complex values intact - Environment variable name validation: Adds regex validation (
/^[A-Za-z_][A-Za-z0-9_]*$/) to ensure only properly formatted environment variable names are treated as keys during paste operations
The changes are contained within the handleKeyValuePaste function in the environment variables component, which is responsible for processing clipboard content when users paste key-value pairs. This component is part of the settings modal's environment management interface, allowing users to efficiently manage their application's environment variables. The fix ensures that legitimate environment variable values containing = characters (such as API endpoints with query parameters) are preserved correctly while maintaining the ability to parse actual key-value pairs from pasted content.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it addresses a specific parsing bug without affecting other functionality
- Score reflects targeted bug fix with improved validation logic that maintains backward compatibility while fixing the core issue
- Pay close attention to the environment variable parsing logic in the
handleKeyValuePastefunction
1 file reviewed, no comments
Summary
fix split for pasting envvars with query params
Type of Change
Testing
Fix splitting envvars with query params
Checklist