Stdweb parsing GET parameters in url


pub fn search(&self) -> Result<String, SecurityError>` [[src]]([[−]](javascript:void(0))

Returns a  `String`  which is a search string, also called a query string, that is a  `String`  containing a '?' followed by the parameters of the URL.

These can then be further parsed via another library.

If I'm reading the docs correctly, stdweb is punting on parsing the url into a HashMap<String, String> to represent the query parameters.

Is there a recommended rust/wasm32 library for doing this in the browser? (I realize it's possible with regex; but I'd prefer to use a real library instead of some adhoc regexes).

Instead of parsing it in Rust, you can use browser's URLSearchParams API.

In JS:

const url = new URL(location);
const params = url.searchParams;
const name = params.get('name'); // String | null

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.