Skip to content

test: Add test for restoring duplicate hashes in patternHasher#6071

Merged
bijin-bruno merged 2 commits intousebruno:mainfrom
barelyhuman:fix/restore-duplicate-hasher
Nov 12, 2025
Merged

test: Add test for restoring duplicate hashes in patternHasher#6071
bijin-bruno merged 2 commits intousebruno:mainfrom
barelyhuman:fix/restore-duplicate-hasher

Conversation

@barelyhuman
Copy link
Contributor

Description

Fix for duplicate names not being replaced

Contribution Checklist:

  • 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.

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.

Copy link
Contributor

Copilot AI left a comment

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 in the patternHasher function where duplicate template variables were not being properly restored. The fix changes the restore logic from using simple string replacement to using a global regex replacement to ensure all occurrences of each hash are replaced.

  • Changed the restore function to use RegExp with global flag instead of simple replace
  • Added a test case to verify that duplicate hashes (e.g., multiple instances of {{name}}) are correctly restored

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/bruno-common/src/utils/template-hasher.ts Fixed the restore function to replace all occurrences of each hash using a global regex instead of replacing only the first occurrence
packages/bruno-common/src/utils/template-hasher.spec.ts Added test case to verify that duplicate template variables are correctly restored

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bijin-bruno bijin-bruno merged commit 631b053 into usebruno:main Nov 12, 2025
7 checks passed
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.

3 participants