Skip to content

Instantly share code, notes, and snippets.

@mminer
Last active April 28, 2025 17:59
Show Gist options
  • Save mminer/821604aba7239dd62193e5591043ba51 to your computer and use it in GitHub Desktop.
Save mminer/821604aba7239dd62193e5591043ba51 to your computer and use it in GitHub Desktop.
Unity function to parse GET query parameters from a URL, in lieu of System.Net.Http.HttpClient.ParseQueryString.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEngine.Networking;
...
static Dictionary<string, string> ParseUrlQuery(string url)
{
var regex = new Regex("[?&]([^=]+)=([^&]*)");
var query = new Uri(url).Query;
return regex.Matches(query).ToDictionary(
static match => match.Groups[1].Value,
static match => UnityWebRequest.UnEscapeURL(match.Groups[2].Value)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment