Innovenergy_trunk/frontend/node_modules/testcafe-hammerhead/lib/utils/string-trim.js

18 lines
1.0 KiB
JavaScript

"use strict";
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
// NOTE: Some websites override the String.prototype.trim method. When we use this function
// in our scripts, we expect it to have the default behavior. Therefore, in order to protect
// ourselves from spoofing, we must use our own implementation. Also, we cannot use the
// String.prototype.trim method because on the client-side it is the same in the top window and
// an iframe window. The client code may override this method in the top window before the
// iframe is initialized, so that the iframe will lose access to the native method.
function default_1(str) {
return typeof str === 'string' ? str.replace(/(^\s+)|(\s+$)/g, '') : str;
}
exports.default = default_1;module.exports = exports.default;