We are using the slug attribute of the product object to construct the url in the routing like:
routing: {
routes: {
product: {
paths: ['product/:productCode/:name', 'product/:productCode'],
paramsMapping: { productCode: 'code', name: 'slug' },
},
},
},
In the default implementation the slug is filled by the ProductNameNormalizer which replaces some special characters.
According to this comment:
/**
* The product slug is used to create pretty URL for links to product detail pages.
*
* The slug typically avoid spaces (`%20`) or other characters that are encoded in the URL.
*/
slug?: string;
the slug should encode characters like " or space as well. But sadly, it does not.
Two improvement ideas:
- Add correct url encoding in the default implementation as well.
- Use the slug in the default routing config of product urls, so that no customization is needed.
We are using the slug attribute of the product object to construct the url in the routing like:
In the default implementation the slug is filled by the
ProductNameNormalizerwhich replaces some special characters.According to this comment:
the slug should encode characters like " or space as well. But sadly, it does not.
Two improvement ideas: