Last active
April 28, 2025 17:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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