MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / getQueryParameter

Function getQueryParameter

Ports/JavaScriptPort/src/main/webapp/port.js:280–304  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

278}
279
280function getQueryParameter(name) {
281 const loc = (global.window || global).location;
282 if (!loc || !loc.search) {
283 return null;
284 }
285 const search = String(loc.search).charAt(0) === "?" ? String(loc.search).substring(1) : String(loc.search);
286 if (!search) {
287 return null;
288 }
289 const pairs = search.split("&");
290 for (let i = 0; i < pairs.length; i++) {
291 const part = pairs[i];
292 if (!part) {
293 continue;
294 }
295 const eq = part.indexOf("=");
296 const rawKey = eq >= 0 ? part.substring(0, eq) : part;
297 if (decodeURIComponent(rawKey.replace(/\+/g, " ")) !== name) {
298 continue;
299 }
300 const rawValue = eq >= 0 ? part.substring(eq + 1) : "";
301 return decodeURIComponent(rawValue.replace(/\+/g, " "));
302 }
303 return null;
304}
305
306// Gate for port.js's PARPAR:DIAG:* and PARPAR:DIAG:FALLBACK:* log emissions.
307// Opt-in via ``?parparDiag=1`` (same toggle CI uses). Before this gate every

Callers 3

__cn1PortDiagEnabledFunction · 0.70
port.jsFile · 0.70

Calls 6

charAtMethod · 0.65
substringMethod · 0.65
splitMethod · 0.65
indexOfMethod · 0.65
replaceMethod · 0.65
StringClass · 0.50

Tested by

no test coverage detected