Merge pull request #16 from da2x/patch-2

Let querySelector do all the work when finding canonical href
This commit is contained in:
Danny van Kooten 2018-04-25 13:46:59 +02:00 committed by GitHub
commit 0bb0c1356b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -40,8 +40,8 @@ function trackPageview() {
// get the path or canonical
var path = location.pathname + location.search;
var canonical = document.querySelector('link[rel="canonical"]');
if(canonical && canonical.href) {
var canonical = document.querySelector('link[rel="canonical"][href]');
if(canonical) {
path = canonical.href.substring(canonical.href.indexOf('/', 7)) || '/';
}