Skip to content

Fix critical bugs and improve code quality in processenv2#2

Merged
Nexus633 merged 3 commits intomasterfrom
copilot/fix-1f8f0b63-f4a5-41d5-8f8b-8c84ec3c2725
Sep 9, 2025
Merged

Fix critical bugs and improve code quality in processenv2#2
Nexus633 merged 3 commits intomasterfrom
copilot/fix-1f8f0b63-f4a5-41d5-8f8b-8c84ec3c2725

Conversation

Copy link
Contributor

Copilot AI commented Sep 9, 2025

This PR addresses multiple critical issues found in the processenv2 codebase that were causing 8 test failures and significant code quality problems.

Issues Fixed

1. Equals Sign Handling in Values

The previous implementation incorrectly split environment variable values on all = characters, breaking values like TEST=YG==:

// Before: splitVal = val.split('=')  // ["TEST", "YG", "", ""]
// After: Proper substring extraction
const firstEquals = val.indexOf('=');
const value = val.substring(firstEquals + 1);  // "YG=="

2. Quotation Mark Processing

Fixed quotation mark removal to preserve inner quotes while removing only outer ones:

# Before: TEST='"Some Text"' → "Some Text" (inner quotes removed)
# After: TEST='"Some Text"' → "Some Text" (inner quotes preserved)

3. Variable Substitution Support

Extended regex pattern to support lowercase and numeric variable names:

// Before: /\${[A-Z_]+}/g  // Only uppercase
// After: /\${[A-Za-z_][A-Za-z0-9_]*}/g  // Supports lowercase, numbers

4. Escape Sequence Handling

Implemented proper escape sequence processing for \n, \\, etc.:

TEST=Some Text\nMore Text  # Now correctly converts to actual newline
TEST=Some Text\\More Text  # Now correctly converts to single backslash

5. Comment Detection Logic

Improved hashtag handling to distinguish between values containing # and actual comments:

TEST=Some Text#More Text     # Hashtag preserved as part of value
TEST=Some Text # comment     # Comment properly filtered out

Code Quality Improvements

  • Formatting: Fixed replaceNestedChars.js which was completely unformatted (single line)
  • Documentation: Enhanced JSDoc comments with complete parameter descriptions
  • Input Validation: Added type checking and error handling throughout
  • Error Handling: Added try-catch blocks for file operations with proper warnings

Test Results

  • ✅ All 25 tests now pass (previously 8 failing)
  • ✅ No ESLint errors or warnings
  • ✅ Maintained high code coverage

The library now correctly handles all documented features and edge cases, making it more robust and reliable for production use.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Nexus633 Nexus633 marked this pull request as ready for review September 9, 2025 17:14
Copilot AI and others added 2 commits September 9, 2025 17:17
Co-authored-by: Nexus633 <10248499+Nexus633@users.noreply.github.com>
…dation

Co-authored-by: Nexus633 <10248499+Nexus633@users.noreply.github.com>
Copilot AI changed the title [WIP] prüfe den Code und gebe mir verbesserungsvorschläge Fix critical bugs and improve code quality in processenv2 Sep 9, 2025
Copilot AI requested a review from Nexus633 September 9, 2025 17:23
Copy link
Owner

@Nexus633 Nexus633 left a comment

Choose a reason for hiding this comment

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

fix

@Nexus633 Nexus633 merged commit 79e731d into master Sep 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants