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/client/providers/CallProvider/lib/parseStringToIceServers.ts

21 lines
666 B

import type { IceServer } from '../definitions/IceServer';
export const parseStringToIceServer = (server: string): IceServer => {
const credentials = server.trim().split('@');
const urls = credentials.pop() as string;
const [username, credential] = credentials.length === 1 ? credentials[0].split(':') : [];
return {
urls,
...(username &&
credential && {
username: decodeURIComponent(username),
credential: decodeURIComponent(credential),
}),
};
};
export const parseStringToIceServers = (string: string): IceServer[] => {
const lines = string.trim() ? string.split(',') : [];
return lines.map((line) => parseStringToIceServer(line));
};