/** * normalizeSteamId() * * @description Accepts either a plain numeric Steam app ID or a * store.steampowered.com URL and returns the numeric app ID. * Returns "" when the input is empty/missing (manual non-scrape flow * looks games up by title instead) and `null` when the input is * neither digits nor a recognized Steam Store URL. */ const normalizeSteamId = (value) => { const raw = String(value ?? "").trim(); if (!raw) return ""; const urlMatch = raw.match( /store\.steampowered\.com\/(?:agecheck\/)?app\/(\d+)/, ); if (urlMatch) return urlMatch[1]; if (/^\d+$/.test(raw)) return raw; return null; }; export default normalizeSteamId;