mirror of
https://github.com/jambonz/chrome-extension-dialer.git
synced 2026-05-06 08:47:01 +00:00
29 lines
641 B
TypeScript
29 lines
641 B
TypeScript
function normalizeNumber(number: string): string {
|
|
if (/^(sips?|tel):/i.test(number)) {
|
|
return number;
|
|
} else if (/@/i.test(number)) {
|
|
return number;
|
|
} else if (
|
|
number.startsWith("app-") ||
|
|
number.startsWith("queue-") ||
|
|
number.startsWith("conference-")
|
|
) {
|
|
return number;
|
|
} else {
|
|
return number.replace(/[()\-. ]*/g, "");
|
|
}
|
|
}
|
|
|
|
function randomId(prefix: string): string {
|
|
const id: string = [...Array(16)]
|
|
.map(() => Math.floor(Math.random() * 16).toString(16))
|
|
.join("");
|
|
if (prefix) {
|
|
return `${prefix}-${id}`;
|
|
} else {
|
|
return id;
|
|
}
|
|
}
|
|
|
|
export { normalizeNumber, randomId };
|