Skip to content

Conversation

@barelyhuman
Copy link
Contributor

Description

adds a utility function that hashes input strings containing the passed in pattern and allows for restoration of the original string. It includes support for custom matchers and handles cases where no variables are matched.

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.

This utility function hashes input strings containing variables and allows for restoration of the original string. It includes support for custom matchers and handles cases where no variables are matched.
Copilot AI review requested due to automatic review settings November 7, 2025 12:48
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 introduces a new utility function patternHasher that replaces variable patterns (like {{var_name}}) in strings with unique hashes, and provides a mechanism to restore the original patterns. This is specifically designed for sanitizing URLs containing Bruno variables before validation.

Key Changes:

  • Implements djb2 hashing algorithm to generate unique identifiers for matched patterns
  • Provides a restore function to reverse the hashing operation
  • Includes comprehensive test coverage with multiple edge cases

Reviewed Changes

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

File Description
packages/bruno-common/src/utils/template-hasher.ts New utility implementing pattern hashing with configurable regex support
packages/bruno-common/src/utils/template-hasher.spec.ts Test suite covering basic hashing, multiple patterns, custom matchers, and non-matching cases

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

@bijin-bruno bijin-bruno merged commit 68b2625 into usebruno:main Nov 7, 2025
6 of 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