1
0
Fork 0
mirror of synced 2024-09-17 17:57:47 +12:00
budibase/apps/account-portal/packages/server/node_modules/strip-bom/index.js
2023-10-17 10:59:46 +02:00

15 lines
348 B
JavaScript

'use strict';
module.exports = string => {
if (typeof string !== 'string') {
throw new TypeError(`Expected a string, got ${typeof string}`);
}
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
// conversion translates it to FEFF (UTF-16 BOM)
if (string.charCodeAt(0) === 0xFEFF) {
return string.slice(1);
}
return string;
};