1// Form Logic: API utilities 2// Dependencies: none 3// 4// Provides: 5// - ipGeoUserLocation(apiUrl) â fetches the user's ISO country code via IP geolocation 6// 7// Originally from sw-global/dev/scripts/modules/sw-api.js (ES module). 8// Converted to a plain global script for direct wp_enqueue_script enqueueing. 9// The modules/ version is kept in place for other themes that import it via ES modules. 10 11async function ipGeoUserLocation(apiUrl) { 12 const urlParams = new URLSearchParams(window.location.search); 13 const ipOverride = urlParams.get("ipmask"); 14 let path = "api/ip-geo/user-location"; 15 if (/^[0-9a-f.:]+$/.test(ipOverride)) { 16 path += `?ipAddress=${encodeURIComponent(ipOverride)}`; 17 } 18 const res = await fetch(`${apiUrl}/${path}`); 19 return await res.json(); 20}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.