Skip to content
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

Code refactor in main.ts #1348

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

donneypr
Copy link
Contributor

✨ Pull Request

📓 Referenced Issue

Fixes: N/A (This is a code refactor with no associated issue)

ℹ️ About the PR

This PR simplifies and optimizes the logic for modifying the Content-Security-Policy (CSP) header in the Electron app. The refactor replaces repetitive replace calls with a dynamic and scalable approach using a replacements object and a reduce function.

Key Changes:

  • Replaced repetitive string replacement logic with a loop over a replacements object.
  • Improved readability by encapsulating logic in the modifyCSPHeader function.
  • Reduced lines of code for better maintainability and scalability.
  • This change is non-breaking and ensures the behaviour remains consistent while improving code quality.

🖼️ Testing Scenarios / Screenshots

Manual Validation:

  • Opened the Electron app and verified that the CSP headers were correctly updated to include BROWSER_SYNC_HOST in default-src, script-src, connect-src, and other policies.

Debugging Tools:

  • Used electron-debug to confirm that headers are applied without errors during runtime.

Regression Testing:

  • Ensured no existing functionality is broken by the refactor.

Before & After Comparison:

  • No UI/visual changes; this is an internal code improvement. Functionality remains the same.

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.

1 participant