Youre right. Will fix.

Sent from a phone

On 16/08/2013, at 21:36, "Chris Tavares" <notifications@github.com<mailto:notifications@github.com>> wrote:


In lib/util/util.js:

> @@ -239,6 +239,16 @@ exports.stringIsDate = function (date) {
>  };
>
>  /**
> +* Removes the BOM from a string.
> +*
> +* @param {string} str The string from where the BOM is to be removed
> +* @return {string} The string without the BOM.
> +*/
> +exports.removeBOM = function (str) {
> +  return str.replace('\ufeff', '');


Should also remove \uffef, in case it's a big-endian string.

Although, you should probably rewrite this to just chop off the first character, like so:

if (str.charCodeAt(0) === 0xfeff || str.charCodeAt(0) === 0xffef) {
  str = str.substring(1);
}
return str;


Otherwise str.replace will go looking throughout the string for the BOM and replace the first one it finds, even if it's not a the beginning. And if the string does NOT include the BOM, the str.replace call will have to traverse the entire string before giving up.

-
Reply to this email directly or view it on GitHub<https://github.com/WindowsAzure/azure-sdk-for-node/pull/973/files#r5824187>.