Let querySelector do all the work

This commit is contained in:
Daniel Aleksandersen 2018-04-25 13:27:50 +02:00 committed by GitHub
parent 32f4299656
commit 1b007cdda9
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)) || '/';
}