Uncaught TypeError: Cannot call method 'match' of null


#1

Widget.js is failing on:

provide(“util/uri”,function(a){using(“util/querystring”,“util/util”,function(b,c){function d(a){var b;return a.match(/^https?:///)?a:(b=location.host,location.port.length>0&&(b+=":"+location.port),[location.protocol,"//",b,a].join(""))}function e(){var a=document.getElementsByTagName(“link”);for(var b=0,c;c=a[b];b++)if(c.getAttribute(“rel”)==“canonical”)return d(c.getAttribute(“href”));return null}function f(){var a=document.getElementsByTagName(“a”),b=document.getElementsByTagName(“link”),d=/\bme\b/,e=/^https?://(www.)?twitter.com/([a-zA-Z0-9_]+)$/,f=c.array(a).concat(c.array(b)),g,h,i;for(var j=0,k;k=f[j];j++){h=k.getAttribute(“rel”),i=k.getAttribute(“href”);if(h&&i&&h.match(d)&&(g=i.match(e)))return g[2]}}a({absolutize:d,getCanonicalURL:e,getScreenNameFromPage:f})})});

This page is our production page without the error:

I’ve added the latest twitter button to our development servers and I’m getting the above error.


#2

Which button are you attempting to add? What other Twitter-related buttons or widgets do you have on the page? Are you using the deprecated @Anywhere framework at all?


#3

Tweet

Share link button - no other twitter widgets on the page.


#4

I should also point out, that the button does not render at all - just the linked “Tweet” text.


#5

thanks @iamjasonday


#6

Hi Jason,

Odd – your page looks like one that should house this button without issue. If it’s not morphing from a conventional link, it usually means that the Javascript has failed to load for some reason.

What happens if you change the lazy Javascript inclusion portion from:
js.src="//platform.twitter.com/widgets.js"

to:
js.src=“https://platform.twitter.com/widgets.js


#7

I’ll give it a shot. I notice that the body tag is not getting: data-twttr-rendered=“true”

Next question, I’m noticing that the og tag for url on this page does not resolve correctly (it actually resolves to our homepage because it’s configured incorrectly.). Could this also be impacting the script?


#8

I don’t think it’s likely that it is – however, one thing you might want to do is explicitly set the data-url parameter/property on the HREF with the current page’s URL – that way you’re giving the system additional hints as to which page is the tweet button is on.


#9

I have similar issue, because of code:

if (g.src.match(/loadrunner.js(?|#|$)/)) {
s = g;
break
}

There are script tags on the page which do not have src attribute. Typically it should be just empty string, but I’m using meteor.js framework, and I believe they are doing some magic with DOM.
Nevertheless, I think the simple check wouldn’t be bad here:

if (g.src && g.src.match(/loadrunner.js(?|#|$)/)) {
s = g;
break
}

Or smth like that.


#10

#11