Skip to content

Conversation

@Niyibitanga
Copy link
Contributor

Update url processing to keep certain parameters

@Niyibitanga Niyibitanga requested a review from Copilot October 31, 2025 18:23
Copy link

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 adds a new keep configuration option to preserve specific URL query parameters from being truncated during URL scrubbing. The feature reorders query strings to move "kept" parameters to the front, ensuring they remain within the maxUrlLength limit when truncation occurs.

Key changes:

  • Added keep parameter to the Config interface alongside existing drop parameter
  • Implemented logic to reorder query parameters, placing kept parameters first
  • Initialized default keep configuration as an empty array

Reviewed Changes

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

File Description
packages/clarity-js/types/core.d.ts Added keep?: string[] to Config interface
packages/clarity-js/src/core/config.ts Initialized default keep configuration as empty array
packages/clarity-js/src/core/scrub.ts Implemented query parameter reordering logic to prioritize kept parameters before truncation

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

@Niyibitanga Niyibitanga requested a review from Copilot October 31, 2025 18:41
@Niyibitanga Niyibitanga marked this pull request as ready for review October 31, 2025 18:41
@Niyibitanga Niyibitanga changed the title Ninosa/url update Update Url Processing Oct 31, 2025
Copy link

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

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


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

}

if (truncate) {
result = result.substring(0, maxUrlLength);
Copy link
Member

Choose a reason for hiding this comment

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

Should keep override truncate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting we don't truncate if keep portion exceeds maxUrlLength?

Copy link
Member

@toby-walker toby-walker Jan 22, 2026

Choose a reason for hiding this comment

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

yes. I believe we should:

  • Split the URL into its components: path, domain, query, URL hash.
  • Apply the drop logic
  • Form the keep part if keep list is non-empty
  • Apply the truncatation t o the components:
    • iif truncation on the core (path) part should we really truncate?
    • Add the keep parameters to the truncated core
  • Add any remaining parameters if truncation is not needed. Try to truncate at parameter unit not just a simple string truncate.

the above would be ideal

Copy link

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

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

Copy link

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

Copilot reviewed 3 out of 4 changed files in this pull request and generated 17 comments.

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.

4 participants