Add backend unit/integration tests, Playwright e2e tests, README, cookie Secure fix
SonarQube Analysis / sonarqube (push) Successful in 4m20s
SonarQube Analysis / sonarqube (push) Successful in 4m20s
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
export function toCents(price: string | number): number {
|
||||
const n = typeof price === 'string' ? parseFloat(price) : price;
|
||||
if (Number.isNaN(n) || n < 0) {
|
||||
throw new Error('invalid price');
|
||||
}
|
||||
return Math.round(n * 100);
|
||||
}
|
||||
|
||||
export function formatPrice(cents: number): string {
|
||||
return `$${(cents / 100).toFixed(2)}`;
|
||||
}
|
||||
|
||||
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
export function isValidEmail(email: string): boolean {
|
||||
return EMAIL_RE.test(email.trim());
|
||||
}
|
||||
|
||||
export const MARKETING_CONSENT_TEXT =
|
||||
'I want to receive occasional emails about new one-of-a-kind items from Redefined Designs. I can unsubscribe at any time.';
|
||||
Reference in New Issue
Block a user