|var link = !!document.querySelector("link[rel='canonical']") ? document.querySelector("link[rel='canonical']") : document.createElement('link');|
|link.setAttribute('href', location.protocol + '//' + location.host + location.pathname);|
You're not going to find it in the page source though, because it's added to the DOM within the browser, rather than as part of the page source. But I can't say for sure if Google bots would see it - check out this this article for an in depth discussion of if this works.
I've read this article and to be honest I got confused. Although that says Google stated that does not accept or read tags generated with JS in the end canonical urls got passed after a few days.
But those lines made me really skeptical:
So the only road is to test and see if it works?