[IMP] *: remove trailing slash from routes

* http, http_routing, website, website_sale_comparison

At an crawling engine/SEO level, having trailing slashes or not in URLs doesn't
change anything.
Still, whichever solution is chosen, it should be done consistantly: either all
URLs have trailing slashes, or none of them have it.

See https://developers.google.com/search/blog/2010/04/to-slash-or-not-to-slash
" Be consistent with the preferred version. Use it in your internal links. If
  you have a Sitemap, include the preferred version (and don't include the
  duplicate URL). "

opw-2505818
opw-2513575
Community: https://github.com/odoo/odoo/pull/71065
Enterprise: https://github.com/odoo/enterprise/pull/18615
This commit is contained in:
Romain Derie
2021-06-03 12:07:32 +00:00
parent 119d9437e0
commit c1ae086cdb
5 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -384,7 +384,7 @@ class Website(Home):
}
return request.render("website.list_website_pages", values)
@http.route(['/website/add/', '/website/add/<path:path>'], type='http', auth="user", website=True, methods=['POST'])
@http.route(['/website/add', '/website/add/<path:path>'], type='http', auth="user", website=True, methods=['POST'])
def pagenew(self, path="", noredirect=False, add_menu=False, template=False, **kwargs):
# for supported mimetype, get correct default template
_, ext = os.path.splitext(path)
@@ -7,7 +7,7 @@ import json
class WebsiteSaleProductComparison(WebsiteSale):
@http.route('/shop/compare/', type='http', auth="public", website=True, sitemap=False)
@http.route('/shop/compare', type='http', auth="public", website=True, sitemap=False)
def product_compare(self, **post):
values = {}
product_ids = [int(i) for i in post.get('products', '').split(',') if i.isdigit()]
@@ -67,7 +67,7 @@ var ProductComparison = publicWidget.Widget.extend(VariantMixin, {
$(document.body).on('click.product_comparaison_widget', '.o_comparelist_remove', function (ev) {
self._removeFromComparelist(ev);
self.guard.exec(function() {
var new_link = '/shop/compare/?products=' + self.comparelist_product_ids.toString();
var new_link = '/shop/compare?products=' + self.comparelist_product_ids.toString();
window.location.href = _.isEmpty(self.comparelist_product_ids) ? '/shop' : new_link;
});
});
@@ -236,7 +236,7 @@ var ProductComparison = publicWidget.Widget.extend(VariantMixin, {
this.$('.o_comparelist_products').addClass('d-md-block');
if (this.comparelist_product_ids.length >=2) {
this.$('.o_comparelist_button').addClass('d-md-block');
this.$('.o_comparelist_button a').attr('href', '/shop/compare/?products='+this.comparelist_product_ids.toString());
this.$('.o_comparelist_button a').attr('href', '/shop/compare?products='+this.comparelist_product_ids.toString());
}
}
},
@@ -141,7 +141,7 @@ class TestUi(odoo.tests.HttpCase):
self.assertEqual(text_varieties.replace(' ', '').replace('\n', ''), "GrapeVarietiesCabernetSauvignon,Merlot,CabernetFranc,PetitVerdot")
# Case compare page
res = self.url_open('/shop/compare/?products=%s' % ','.join(str(id) for id in self.variants_margaux.ids))
res = self.url_open('/shop/compare?products=%s' % ','.join(str(id) for id in self.variants_margaux.ids))
self.assertEqual(res.status_code, 200)
root = etree.fromstring(res.content, etree.HTMLParser())
@@ -90,7 +90,7 @@
<t t-if="alt_product_variant_id" t-set="id_list" t-value="id_list + [alt_product_variant_id]"/>
</t>
<t t-set="ids" t-value="','.join([str(id) for id in id_list])"/>
<div><span class='h3'>Suggested alternatives: </span><a t-if="len(id_list) > 1 and is_view_active('website_sale_comparison.add_to_compare')" role="button" class="btn btn-primary" t-attf-href="/shop/compare/?products=#{ids}"><i class="fa fa-exchange"></i> Compare</a></div>
<div><span class='h3'>Suggested alternatives: </span><a t-if="len(id_list) > 1 and is_view_active('website_sale_comparison.add_to_compare')" role="button" class="btn btn-primary" t-attf-href="/shop/compare?products=#{ids}"><i class="fa fa-exchange"></i> Compare</a></div>
</xpath>
</template>