Change to req.get() behaviour

Nick Houghton, May 29 2016


Change in JS functionality

This is a notification of a minor but potentially important change in functionality that might effect your Sandbox behaviour.

The change is to how the req.get() function behaves when no header for the given name is found, previously this incorrectly returns ‘undefined’ as a string, we will be deploying a change over the coming weekend 29th May 2016 that will fix this incorrect behaviour to return a proper JS undefined.

You may have to update some of your Sandbox JavaScript code to suit this subtle new behaviour. Where previously you may have had code like this because of this defect:

if(req.get('HeaderName') == 'undefined')

you can now write the proper:

if(!req.get('HeaderName')) 

or 

if(req.get('HeaderName') === undefined)

A number of Sandboxes with the now incorrect usage have been automatically updated to suit, but yours may have been missed by the search and you will need to update it manually.

Hit us up with any feedback, or raise a ticket on GitHub.