{"record":{"id":"fda1b493d7abdbea","repo":"dotnet/runtime","slug":"urlsearchparams-is-supported-fda1b4","errorCode":null,"errorMessage":"URLSearchParams is supported","messagePattern":"URLSearchParams is supported","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/Common/JavaScript/loader/host-builder.ts","lineNumber":75,"sourceCode":"    withDebugging(level: number): DotnetHostBuilder {\n        mergeLoaderConfig({\n            debugLevel: level\n        });\n        return this;\n    }\n    withMainAssembly(mainAssemblyName: string): DotnetHostBuilder {\n        mergeLoaderConfig({\n            mainAssemblyName: mainAssemblyName\n        });\n        return this;\n    }\n    withApplicationArgumentsFromQuery(): DotnetHostBuilder {\n        if (!globalThis.window) {\n            throw new Error(\"Missing window to the query parameters from\");\n        }\n\n        if (typeof globalThis.URLSearchParams === \"undefined\") {\n            throw new Error(\"URLSearchParams is supported\");\n        }\n\n        const params = new URLSearchParams(globalThis.window.location.search);\n        const values = params.getAll(\"arg\");\n        return this.withApplicationArguments(...values);\n    }\n    withApplicationEnvironment(applicationEnvironment?: string): DotnetHostBuilder {\n        mergeLoaderConfig({\n            applicationEnvironment: applicationEnvironment\n        });\n        return this;\n    }\n    withApplicationCulture(applicationCulture?: string): DotnetHostBuilder {\n        mergeLoaderConfig({\n            applicationCulture: applicationCulture\n        });\n        return this;\n    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/Common/JavaScript/loader/host-builder.ts#L57-L93","documentation":"withApplicationArgumentsFromQuery() also requires globalThis.URLSearchParams. If it is undefined the loader throws. NOTE: the message 'URLSearchParams is supported' is misleading — it is thrown precisely when URLSearchParams is NOT available, and reads like a positive assertion. Treat it as a missing-polyfill error, not a feature statement.","triggerScenarios":"Running in an ancient/embedded JS engine that lacks URLSearchParams (very old browsers, minimal embedded JS shells). Combined with [74]: this guard is reached only when window exists but URLSearchParams does not.","commonSituations":"Legacy embedded WebView; a custom JS shell used for testing that does not implement URLSearchParams; very old Safari/IE; an environment that polyfilled window but not URLSearchParams.","solutions":["Provide a URLSearchParams polyfill before calling withApplicationArgumentsFromQuery (e.g. via core-js or url-search-params-polyfill).","Upgrade the host engine to one with native URLSearchParams (all modern browsers and Node ≥ 10).","Skip withApplicationArgumentsFromQuery and pass args directly via withApplicationArguments()."],"exampleFix":"// before\nbuilder.withApplicationArgumentsFromQuery(); // throws on old engine\n\n// after — polyfill first\nif (typeof globalThis.URLSearchParams === 'undefined') {\n  globalThis.URLSearchParams = (await import('url-search-params-polyfill')).default;\n}\nbuilder.withApplicationArgumentsFromQuery();","handlingStrategy":"type-guard","validationCode":"if (typeof globalThis.URLSearchParams === 'undefined') {\n  throw new Error('URLSearchParams missing — install a polyfill or upgrade the JS engine');\n}","typeGuard":"function supportsUrlSearchParams(g: any): g is { URLSearchParams: typeof URLSearchParams } {\n  return typeof g?.URLSearchParams === 'function';\n}","tryCatchPattern":null,"preventionTips":["Target modern engines or bundle a URLSearchParams polyfill.","Feature-detect before calling withApplicationArgumentsFromQuery.","Maintain a baseline browser-support matrix for your app."],"tags":["environment","polyfill","browser","arguments","config"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}