mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-21 07:09:20 +08:00
* fix: text domains * updated: styled component syntax * update: use await instead of then * fix: prevent application crash in case widget fails to load * add: generated info tip card * update: refactor function
28 lines
908 B
JavaScript
28 lines
908 B
JavaScript
export const checkCompanyName = (companyName) => {
|
|
return typeof companyName === 'string' && companyName.trim().length > 0;
|
|
};
|
|
|
|
export const checkEmail = (email) => {
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
return emailRegex.test(email);
|
|
};
|
|
|
|
export const checkDomain = (domain) => {
|
|
// Support IDNs
|
|
const domainRegex =
|
|
/^(https?:\/\/)?([a-zA-Z0-9\u00A1-\uFFFF-]+\.)+[a-zA-Z\u00A1-\uFFFF]{2,}\/?$/;
|
|
return domainRegex.test(domain);
|
|
};
|
|
|
|
export const parseContent = (text, replacements) => {
|
|
let updatedText = text;
|
|
|
|
// Replace each placeholder with the corresponding value from replacements
|
|
Object.keys(replacements).forEach((key) => {
|
|
const placeholder = `{${key}}`; // Create placeholder format (e.g., {company_name})
|
|
const value = replacements[key]; // Get the replacement value
|
|
updatedText = updatedText.replace(new RegExp(placeholder, 'g'), value);
|
|
});
|
|
|
|
return updatedText;
|
|
};
|