Skip to content

Conversation

@Harjun751
Copy link
Contributor

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Resolves #2768

Overview of changes:
Prevents the invalid intra-site warning by preventing query parameters from being validated. Adds linkProcessor tests for this case.

Anything you'd like to highlight/discuss:

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Fix invalid intra-link warning when using query parameters


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.66%. Comparing base (a12f57a) to head (97bf455).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2789      +/-   ##
==========================================
- Coverage   71.67%   71.66%   -0.01%     
==========================================
  Files         134      134              
  Lines        7286     7285       -1     
  Branches     1609     1490     -119     
==========================================
- Hits         5222     5221       -1     
- Misses       1937     2018      +81     
+ Partials      127       46      -81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 pull request fixes an invalid intra-link warning that was incorrectly triggered when links contained URL query parameters. The issue occurred because the validation logic was treating the entire URL (including query parameters) as the path to validate, rather than just the pathname portion.

Changes:

  • Modified validateIntraLink function to strip query parameters from URLs before validation
  • Added comprehensive test coverage for links with query parameters in various scenarios

Reviewed changes

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

File Description
packages/core/src/html/linkProcessor.ts Added logic to remove query parameters from resource paths before validation, preventing false positive warnings
packages/core/test/unit/html/linkProcessor.test.ts Added 6 new test cases covering query parameters with .html extensions, no extensions, hash fragments, and combinations thereof

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

Comment on lines 187 to 189
} else if (resourcePathUrl.query) {
// remove query parameters if present
resourcePath = resourcePathUrl.pathname; // eslint-disable-line no-param-reassign
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The use of else if here creates confusion because both conditions handle query parameters differently. When a hash is present, the query parameter is implicitly removed by pathname (line 186). When only a query parameter is present (no hash), it's explicitly handled here. This logic is correct but unnecessarily complex. Consider combining these conditions into a single check that always uses pathname when either hash or query parameters are present, making the intent clearer.

Copilot uses AI. Check for mistakes.
Copy link
Member

@gerteck gerteck left a comment

Choose a reason for hiding this comment

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

Thank you for your help on this 👍

hash = resourcePathUrl.hash.substring(1);
// remove hash portion (if any) in the resourcePath
resourcePath = resourcePathUrl.pathname; // eslint-disable-line no-param-reassign
} else if (resourcePathUrl.query) {
Copy link
Member

@gerteck gerteck Jan 19, 2026

Choose a reason for hiding this comment

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

  • hashes (#) and queries (?) can both exist in the same URL, with the query string usually coming before the hash, e.g. https://example.com/page?param=value#section

so using else-if is probably not the best idea, since it implies mutual exclusion

Since url-parse library already separates pathname, query, hash, we can just set the resourcePath to pathname.

const hash = resourcePathUrl.hash ? resourcePathUrl.hash.substring(1) : undefined;
resourcePath = resourcePathUrl.pathname;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yea, makes sense. Incorporated changes as per your suggestion!

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.

Invalid intra-link warning given when the link has URL parameters

2 participants