arvgta / ajaxify

Ajaxify - The Ajax Plugin
https://4nf.org/
274 stars 124 forks source link

URL not refreshed when using canonical tag #158

Closed arvgta closed 5 years ago

arvgta commented 5 years ago

Here's why the canonical parameter was introduced in the first place - mainly in order to cater for correct URLs in the event of redirects...


The bug can be observed, when:

1) The following (default) value for the canonical tag handling option is in force:

canonical: true

and

2) There is a canonical tag on the pages

and

3) There are internal links to other pages with different URLs but presumably with the same canonical URL


Original bug description:

As you can see from the title, I'm having some issues on WordPress integration. The problem is, everything is working except the URL refresh, but only with taxonomies (categories, tags, custom taxonomies).

http://moam.ulbdesign.com/blog/

For example, when you click on a "category link (grey text above post title)" or "life cycle of the song boxes (they're custom taxonomies)", it goes to the relevant page but the URL doesn't change.


What happens is, that the URL shown in the browser's address bar doesn't change. This happens, because Ajaxify uses the canonical tag, when given, which is probably the same in some scenarios.


Salient code:

doRender2: function() { // Continue render
    var e = $.rq("e"), // Fetch event 
    url = _getURL(e); // Get URL from event
    url = $.rq("can?", url); // Fetch canonical if no hash or parameters in URL
    $.frms("a"); // Ajaxify forms - in content divs only
...
}

especially the line with the comment:

... //Fetch canonical if no hash or parameters in URL

... so there already is a certain safety measure in force, that the canonical URL is not utilised, whenever there is a hash or other parameters in the URL