Skip to content

Comments

Add canonical URL generator#82

Merged
loevgaard merged 1 commit intomasterfrom
feature/73-canonical-url
May 2, 2025
Merged

Add canonical URL generator#82
loevgaard merged 1 commit intomasterfrom
feature/73-canonical-url

Conversation

@vvasiloi
Copy link
Contributor

@vvasiloi vvasiloi commented May 1, 2025

Fixes #73

@vvasiloi vvasiloi force-pushed the feature/73-canonical-url branch from 8c1a8b4 to b8c7536 Compare May 1, 2025 12:13
@codecov
Copy link

codecov bot commented May 1, 2025

Codecov Report

Attention: Patch coverage is 31.57895% with 26 lines in your changes missing coverage. Please review.

Project coverage is 32.63%. Comparing base (d0a7063) to head (af676a6).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
.../EventSubscriber/Search/CanonicalUrlSubscriber.php 0.00% 13 Missing ⚠️
src/Controller/Action/SearchAction.php 0.00% 8 Missing ⚠️
src/Event/Search/SearchResponseCreated.php 0.00% 2 Missing ⚠️
src/Form/Builder/RangeFilterFormBuilder.php 0.00% 2 Missing ⚠️
src/UrlGenerator/CanonicalUrlGenerator.php 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #82      +/-   ##
============================================
- Coverage     32.69%   32.63%   -0.07%     
- Complexity      660      668       +8     
============================================
  Files           124      127       +3     
  Lines          2205     2237      +32     
============================================
+ Hits            721      730       +9     
- Misses         1484     1507      +23     

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

@vvasiloi vvasiloi self-assigned this May 1, 2025
@vvasiloi vvasiloi force-pushed the feature/73-canonical-url branch from b8c7536 to 0f5b958 Compare May 2, 2025 09:25

interface CanonicalUrlGeneratorInterface
{
public function generate(Request $request, array $parameters = []): string;
Copy link
Member

Choose a reason for hiding this comment

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

What were your thoughts with the array $parameters = [] argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It allows the user to customise the URL generation. For example, you could pass some query parameters you want to keep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One could decorate the generator, do some shenanigans with the query parameters to build a parameters array and pass it to the inner generator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added a test case for it.

@vvasiloi vvasiloi force-pushed the feature/73-canonical-url branch 3 times, most recently from 4db2a75 to 7cdc1d3 Compare May 2, 2025 10:06
@vvasiloi vvasiloi force-pushed the feature/73-canonical-url branch from 7cdc1d3 to af676a6 Compare May 2, 2025 10:18
@loevgaard loevgaard merged commit f30e146 into master May 2, 2025
27 of 38 checks passed
@loevgaard loevgaard deleted the feature/73-canonical-url branch May 2, 2025 10:24
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.

[Feature request]: Add canonical tag on filtered pages

2 participants