SPContext.js ‘UpperCase’ of undefined issue

In a SharePoint MVC hosted app the ‘spcontext.js’ files has a piece of code that will append each hyperlink with the ‘SPHostUrl’ attribute.


But I ran into the fact that the script was crashing for some reason…
I added this piece

if (authority == null)
return false;

Into the file so it does not do an UpperCase on the next line because of the fact that the object is null

Modified function:

// Appends SPHostUrl as query string to all the links which point to current domain.
function appendSPHostUrlToLinks(spHostUrl, currentAuthority) {
.filter(function () {
var authority = getAuthorityFromUrl(this.href);

if (authority == null)

return false;

if (!authority && /^#|:/.test(this.href)) {
// Filters out anchors and urls with other unsupported protocols.
return false;
return authority.toUpperCase() == currentAuthority;
.each(function () {
if (!getSPHostUrlFromQueryString(this.search)) {
if (this.search.length > 0) {
this.search += “&” + SPHostUrlKey + “=” + spHostUrl;
else {
this.search = “?” + SPHostUrlKey + “=” + spHostUrl;



Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit /  Bijwerken )

Google photo

Je reageert onder je Google account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s