fix: normalize collection pathnames in EnvironmentSecretsStore#7283
fix: normalize collection pathnames in EnvironmentSecretsStore#7283bijin-bruno merged 3 commits intousebruno:mainfrom
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
WalkthroughNormalize environment collection paths to POSIX form by introducing and using a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/bruno-electron/src/store/env-secrets.js`:
- Line 5: The posixifyPath helper currently lacks JSDoc and will throw on
non-string inputs; add a short JSDoc above posixifyPath describing its purpose,
param (p: string | unknown) and return (string | same-type) and update the
implementation in posixifyPath to first guard non-strings (e.g., if typeof p !==
'string' return p) so calls like collectionPathname or c.path that may be
undefined/null don't throw; keep the replace behavior for string inputs
(p.replace(/\\/g, '/')) and ensure the function name posixifyPath is used
consistently where referenced.
| const Store = require('electron-store'); | ||
| const { encryptStringSafe } = require('../utils/encryption'); | ||
|
|
||
| const posixifyPath = (p) => p.replace(/\\/g, '/'); |
There was a problem hiding this comment.
Add JSDoc and guard non-string inputs in posixifyPath.
This helper is a new abstraction but lacks JSDoc, and it will throw if collectionPathname or stored c.path is undefined/null. That’s a behavior change vs. the previous direct comparison (which was safely false). Consider a safe guard and document the intent.
🔧 Suggested update
+/**
+ * Normalizes collection paths to POSIX-style separators.
+ * Returns the input unchanged when it is not a string.
+ */
-const posixifyPath = (p) => p.replace(/\\/g, '/');
+const posixifyPath = (p) => (typeof p === 'string' ? p.replace(/\\/g, '/') : p);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const posixifyPath = (p) => p.replace(/\\/g, '/'); | |
| /** | |
| * Normalizes collection paths to POSIX-style separators. | |
| * Returns the input unchanged when it is not a string. | |
| */ | |
| const posixifyPath = (p) => (typeof p === 'string' ? p.replace(/\\/g, '/') : p); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/bruno-electron/src/store/env-secrets.js` at line 5, The posixifyPath
helper currently lacks JSDoc and will throw on non-string inputs; add a short
JSDoc above posixifyPath describing its purpose, param (p: string | unknown) and
return (string | same-type) and update the implementation in posixifyPath to
first guard non-strings (e.g., if typeof p !== 'string' return p) so calls like
collectionPathname or c.path that may be undefined/null don't throw; keep the
replace behavior for string inputs (p.replace(/\\/g, '/')) and ensure the
function name posixifyPath is used consistently where referenced.
* fix: normalize collection pathnames in EnvironmentSecretsStore * fix * fix
Description
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit