Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-transition-group": "^4.4.5",
"trim": "^1.0.1",
"url-join": "^1.1.0",
"validator": "^13.15.22"
},
Expand Down
3 changes: 1 addition & 2 deletions src/avatar/gravatar_provider.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import blueimp from 'blueimp-md5';
import trim from 'trim';
import jsonp from '../utils/jsonp_utils';
import { validateEmail } from '../field/email';

const md5 = blueimp.md5 || blueimp;

function normalize(str) {
return typeof str === 'string' ? trim(str.toLowerCase()) : '';
return typeof str === 'string' ? str.toLowerCase().trim() : '';
}

export function displayName(email, cb) {
Expand Down
3 changes: 1 addition & 2 deletions src/connection/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '../../field/index';
import { dataFns } from '../../utils/data_utils';
import sync from '../../sync';
import trim from 'trim';
import { defaultDirectory } from '../../core/tenant';
import { findADConnectionWithoutDomain } from '../../connection/enterprise';

Expand Down Expand Up @@ -41,7 +40,7 @@ function assertMaybeEnum(opts, name, a) {

function assertMaybeString(opts, name) {
const valid =
opts[name] === undefined || (typeof opts[name] === 'string' && trim(opts[name]).length > 0);
opts[name] === undefined || (typeof opts[name] === 'string' && opts[name].trim().length > 0);
if (!valid)
l.warn(opts, `The \`${name}\` option will be ignored, because it is not a non-empty string.`);
return valid;
Expand Down
3 changes: 1 addition & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { isSmallScreen } from '../utils/media_utils';
import { endsWith } from '../utils/string_utils';
import { getLocationFromUrl, getOriginFromUrl } from '../utils/url_utils';
import * as i18n from '../i18n';
import trim from 'trim';
import * as gp from '../avatar/gravatar_provider';
import { dataFns } from '../utils/data_utils';
import { clientConnections, hasFreeSubscription } from './client/index';
Expand Down Expand Up @@ -201,7 +200,7 @@ function extractUIOptions(id, options) {
closable: closable,
hideMainScreenTitle: !!hideMainScreenTitle,
labeledSubmitButton: undefined === labeledSubmitButton ? true : !!labeledSubmitButton,
language: undefined === options.language ? 'en' : trim(options.language || '').toLowerCase(),
language: undefined === options.language ? 'en' : (options.language || '').trim().toLowerCase(),
dict: typeof options.languageDictionary === 'object' ? options.languageDictionary : {},
disableWarnings: options.disableWarnings === undefined ? false : !!options.disableWarnings,
mobile: undefined === options.mobile ? false : !!options.mobile,
Expand Down
3 changes: 1 addition & 2 deletions src/field/email.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import trim from 'trim';
import _isEmail from 'validator/lib/isEmail';

import { setField } from './index';
Expand All @@ -13,7 +12,7 @@ export function isEmail(str, strictValidation = false) {
if (typeof str !== 'string') {
return false;
}
const trimmed = trim(str);
const trimmed = str.trim();
return strictValidation
? _isEmail(str)
: trimmed.indexOf('@') >= 0 && trimmed.indexOf('.') >= 0 && trimmed.indexOf(' ') === -1;
Expand Down
9 changes: 4 additions & 5 deletions src/field/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Map } from 'immutable';
import trim from 'trim';
import OptionSelectionPane from './option_selection_pane';
import * as l from '../core/index';

Expand All @@ -10,14 +9,14 @@ const getDefaultValidator = field => {
switch (field) {
case 'family_name':
case 'given_name':
return str => minMax(trim(str), 1, 150);
return str => minMax(str.trim(), 1, 150);
case 'name':
return str => minMax(trim(str), 1, 300);
return str => minMax(str.trim(), 1, 300);
case 'nickname':
return str => minMax(trim(str), 1, 300);
return str => minMax(str.trim(), 1, 300);

default:
return str => trim(str).length > 0;
return str => str.trim().length > 0;
}
};

Expand Down
3 changes: 1 addition & 2 deletions src/field/mfa_code.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { setField } from './index';
import { validateEmail } from './email';
import { databaseConnection } from '../connection/database';
import trim from 'trim';

const DEFAULT_VALIDATION = { mfa_code: { length: 6 } };
const regExp = /^[0-9]+$/;

function validateMFACode(str, settings = DEFAULT_VALIDATION.mfa_code) {
const value = trim(str);
const value = str.trim();

// check min value matched
if (value.length < settings.length) {
Expand Down
5 changes: 2 additions & 3 deletions src/field/username.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { setField } from './index';
import { validateEmail } from './email';
import { databaseConnection } from '../connection/database';
import trim from 'trim';

const DEFAULT_CONNECTION_VALIDATION = { username: { min: 1, max: 15 } };
const regExp = /^[a-zA-Z0-9_+\-.!#\$\^`~@']*$/;
Expand All @@ -15,10 +14,10 @@ function validateUsername(
// If the connection does not have validation settings, it should only check if the field is empty.
// validateFormat overrides this logic to disable validation on login (login should never validate format)
if (!validateFormat || settings == null) {
return trim(str).length > 0;
return str.trim().length > 0;
}

const lowercased = trim(str.toLowerCase());
const lowercased = str.toLowerCase().trim();

// check min value matched
if (lowercased.length < settings.min) {
Expand Down
3 changes: 1 addition & 2 deletions support/playground/assets/remember.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ require.register("yields-uniq-selector/index.js", function(exports, require, mod
*/

var index = require('indexof');
var trim = require('trim');

/**
* Export `uniq`
Expand Down Expand Up @@ -659,7 +658,7 @@ function uniq(el, arr){
*/

function selector(el){
var classname = trim(el.className.baseVal ? el.className.baseVal : el.className);
var classname = (el.className.baseVal ? el.className.baseVal : el.className).trim();
var i = el.parentNode && 9 == el.parentNode.nodeType ? -1 : index(el);

return el.tagName.toLowerCase()
Expand Down