The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/server/lib/ldap/operations/split.ts

30 lines
566 B

export type LDAPVariableSplit = {
operation: 'split';
pattern: string;
indexToUse?: number;
};
export function executeSplit(input: string, operation: LDAPVariableSplit): string | undefined {
if (!operation.pattern) {
throw new Error('Invalid SPLIT operation.');
}
if (!input) {
return input;
}
const result = input.split(operation.pattern);
if (!result) {
return;
}
if (typeof operation.indexToUse === 'number') {
if (result.length > operation.indexToUse) {
return result[operation.indexToUse];
}
return;
}
return result.shift();
}