Skip to content

[Bug]: Decode functionality in the Base64 Encoder/Decoder tool does not work. #259

Merged
spring1843 merged 3 commits into
spring1843:mainfrom
Shahzaib342:fix-issue136
Dec 6, 2025
Merged

[Bug]: Decode functionality in the Base64 Encoder/Decoder tool does not work. #259
spring1843 merged 3 commits into
spring1843:mainfrom
Shahzaib342:fix-issue136

Conversation

@Shahzaib342

Copy link
Copy Markdown
Contributor

[Bug]: Decode functionality in the Base64 Encoder/Decoder tool does not work.

#136

Pull Request

📋 Description

🔧 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or modification
  • 🔧 Build/CI configuration change

📱 Screenshots/Videos

📝 Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

🔗 Related Issues

📋 Additional Notes

@netlify

netlify Bot commented Dec 2, 2025

Copy link
Copy Markdown

Deploy Preview for freedevtool ready!

Name Link
🔨 Latest commit ca826ae
🔍 Latest deploy log https://app.netlify.com/projects/freedevtool/deploys/69338a84646d170008074086
😎 Deploy Preview https://deploy-preview-259--freedevtool.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 bug where the decode functionality in the Base64 Encoder/Decoder tool was broken. The issue was caused by problematic state management logic that interfered with the decode operation.

Key changes:

  • Initialize the encoded text state with the default encoded value instead of an empty string
  • Remove auto-reset logic that was preventing users from typing in the encoded field and decoding
  • Remove unnecessary useEffect hook that encoded on mount (now handled by initial state)
Comments suppressed due to low confidence (1)

client/src/pages/tools/base64-encoder.tsx:74

  • The handleReset function sets encodedText to an empty string, but the initial state now uses DEFAULT_BASE64_ENCODED. For consistency, the reset function should restore the state to match the initial state:
const handleReset = () => {
  setPlainText(DEFAULT_BASE64);
  setEncodedText(DEFAULT_BASE64_ENCODED);
  setError(null);
};

This ensures that clicking "Reset" returns the component to the exact same state as when it first loads.

  const handleReset = () => {
    setPlainText(DEFAULT_BASE64);
    setEncodedText("");
    setError(null);
  };

Comment on lines 66 to 68
const handleEncodedTextChange = (value: string) => {
setEncodedText(value);
if (plainText !== DEFAULT_BASE64) {
setPlainText(DEFAULT_BASE64);
}
};

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

The decode functionality fix lacks test coverage. Similar tools in the repository (e.g., json-yaml-converter.spec.ts, url-encoder.spec.ts) have comprehensive e2e tests that verify their encode/decode behavior. Consider adding tests to tests/e2e/tools/base64.spec.ts that verify:

  1. The encode button correctly encodes plain text to Base64
  2. The decode button correctly decodes Base64 to plain text
  3. The default values are displayed correctly on load
  4. The reset button works correctly

This will help prevent regression of the bug that was just fixed.

Copilot uses AI. Check for mistakes.
@spring1843 spring1843 merged commit ac466b4 into spring1843:main Dec 6, 2025
5 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.

3 participants