When a URL has a trailing slash in it, the SnowPlow js script throws an error:
Uncaught TypeError: Cannot read property 'length' of null
at g (lnATJXGQ9zZtMi42LjA=.js:37)
at lnATJXGQ9zZtMi42LjA=.js:37
at lnATJXGQ9zZtMi42LjA=.js:31
at eval (eval at ar (lnATJXGQ9zZtMi42LjA=.js:49), <anonymous>:10:9)
at Function.ax (lnATJXGQ9zZtMi42LjA=.js:52)
at Object.addFormListeners (lnATJXGQ9zZtMi42LjA=.js:31)
at Array.<anonymous> (lnATJXGQ9zZtMi42LjA=.js:73)
at s (lnATJXGQ9zZtMi42LjA=.js:59)
at HTMLDocument.t (lnATJXGQ9zZtMi42LjA=.js:59)
Example (foo) URL: example.com/some/url/ will throw an error.
If adding something as simple as a # to the end of the URL, the error does not occur.
Example (foo) URL: example.com/some/url/# will NOT throw an error.
Adding a query param however does NOT remove the error.
Example (foo) URL: example.com/some/url/?foo will throw an error.
It appears as though SnowPlow is assuming that if there is a trailing / there will always be a value following.
The little info I have regarding implementation is the following:
- The version is 2.6.0
- The script is inserted into the document via Google Tag Manager
- The following (although obfuscated) code is the guilty party:
d.getCssClasses = function(i) {
return i.className.match(/\S+/g)
};
function g(j, n) {
var m = d.getCssClasses(j), l;
for (l = 0; l < m.length; l++) { // !! THIS IS THE OCCURRENCE OF THE ERROR !!
if (n[m[l]]) {
return true
}
}
return false
}
Any info would be much appreciated. Thanks!