MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / parseExpiryInput

Function parseExpiryInput

static/js/payment.js:378–403  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

376}
377
378function parseExpiryInput(value) {
379 const raw = String(value || "").trim();
380 if (!raw) {
381 return { exp_month: "", exp_year: "" };
382 }
383
384 const slashMatch = raw.match(/^(\d{1,2})\s*\/\s*(\d{1,4})$/);
385 if (slashMatch) {
386 return {
387 exp_month: normalizeMonth(slashMatch[1]),
388 exp_year: normalizeYear(slashMatch[2]),
389 };
390 }
391
392 const digits = raw.replace(/\D/g, "");
393 if (!digits) {
394 return { exp_month: "", exp_year: "" };
395 }
396 if (digits.length <= 2) {
397 return { exp_month: normalizeMonth(digits), exp_year: "" };
398 }
399 return {
400 exp_month: normalizeMonth(digits.slice(0, 2)),
401 exp_year: normalizeYear(digits.slice(2)),
402 };
403}
404
405function normalizeExpiryInputForTyping(value) {
406 const digits = String(value || "").replace(/\D/g, "").slice(0, 6);

Callers 1

collectBillingFormDataFunction · 0.85

Calls 2

normalizeMonthFunction · 0.85
normalizeYearFunction · 0.85

Tested by

no test coverage detected