Closed mlshvdv closed 6 months ago
Do you have an actual real-world use-case for this?
@sindresorhus
For example, the pages https://example.com/posts
and https://example.com/posts?page=1
are the same. When you need to create a canonical URL for a search engine's crawler (to put in <link rel="canonical" href="https://..." />
, the option removeQueryParametersByValue
will help with it to prevent page duplication (https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls)
Another example. The page has a posts list where users can choose post count per page. By default, only 10 records are displayed per page. In that case, we don't need to have page_size=10
in the URL for pagination. But, when the user chooses another number, for example 25
, the full canonical URL for this page must contain page_size=25
.
Alright. Makes sense. I think you should document the use-case in text though. That it's useful when you want to remove query parameters that are the same as the default.
Bump :)
The option
removeQueryParametersByValue
removes query parameters that match the specified values. May be helpful to make a canonical URL.