Skip to content

fix: prevent URL marking within variable patterns in CodeMirror#6680

Merged
sid-bruno merged 1 commit intousebruno:mainfrom
chirag-bruno:fix/prevent-ctrl-click-in-variables
Jan 14, 2026
Merged

fix: prevent URL marking within variable patterns in CodeMirror#6680
sid-bruno merged 1 commit intousebruno:mainfrom
chirag-bruno:fix/prevent-ctrl-click-in-variables

Conversation

@chirag-bruno
Copy link
Collaborator

@chirag-bruno chirag-bruno commented Jan 5, 2026

Description

This PR prevents marking URL in Codemirror for texts with the pattern {{...}}

PR for CMD+Click - #6671

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where URLs appearing within template variables were incorrectly marked as clickable links. The app now properly skips link marking for URLs that exist inside template variable blocks.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

Walkthrough

Modified linkAware.js to prevent marking URLs that occur within template variables ({{...}} syntax). The implementation detects template variable patterns per line and skips URL marking when overlaps occur, preserving existing behavior outside template regions.

Changes

Cohort / File(s) Summary
URL Marking Filter
packages/bruno-app/src/utils/codemirror/linkAware.js
Added pattern matching to identify {{...}} template variable spans and overlap detection logic to prevent marking URLs that fall within these regions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • PR #6422: Refactors URL-marking behavior in linkAware.js to limit marking to visible viewport—related modification to the same marking logic.

Suggested reviewers

  • helloanoop
  • bijin-bruno
  • lohit-bruno
  • naman-bruno

Poem

Templates wrapped in curly braces,
Now hidden from marking places,
URLs skip with gentle grace—
Template lands remain safe space. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing URL marking within variable patterns in CodeMirror, which matches the changeset's core objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bruno-app/src/utils/codemirror/linkAware.js (1)

62-67: Variable pattern regex is correct for all valid Bruno syntax.

The regex /\{\{[^}]*\}\}/g properly matches all variable patterns used in Bruno ({{apiKey}}, {{process.env.HOME}}, {{user id}}, etc.). The pattern correctly prevents matching malformed constructs like {{has}inside}}.

Optional: Consider extracting the regex for clarity.

The pattern could be defined once at module level with a descriptive name. Note: if extracted to a constant, reset lastIndex to 0 before each loop or recreate the regex per line, since the global flag persists state across uses.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8300abe and 54dfb69.

📒 Files selected for processing (1)
  • packages/bruno-app/src/utils/codemirror/linkAware.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/utils/codemirror/linkAware.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/utils/codemirror/linkAware.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (1)
packages/bruno-app/src/utils/codemirror/linkAware.js (1)

68-73: LGTM! Overlap detection is correctly implemented.

The overlap logic correctly identifies when a URL span intersects with any variable span using the condition index < end && lastIndex > start. This mathematical approach handles all edge cases (overlapping, adjacent, before, after) accurately and efficiently uses .some() to short-circuit on the first match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants