internal RouteMask(HttpMethod method, string route = "", string query = "") { if (string.IsNullOrEmpty(route)) { Log.Critical("Route mask instantiated with empty route!", true); } Query = query; Method = method; //If the query is nothing and we have a query in the route //extract the query and substring the route if (route.Contains("?") && string.IsNullOrEmpty(Query)) { Query = route.Substring(route.IndexOf("?")); } //Clean the route of any queries if (route.Contains("?")) { route = route.Substring(0, route.IndexOf("?")); } //Split the route into parts and remove empty strings string[] parts = route.Split('/').Where(t => !string.IsNullOrEmpty(t)).ToArray(); //Set the route segment array to the parts length + 1 if the route ends with / Segments = new RouteMaskSegment[ parts.Length + (route.EndsWith("/") ? 1 : 0) ]; for (int i = 0; i < parts.Length; i++) { Segments[i] = new RouteMaskSegment(parts[i]); } //If the route ends with / then add it to the array if (route.EndsWith("/")) { //This as a / at the end of the url //signifying it's an index Segments[Segments.Length - 1] = new RouteMaskSegment("/"); } }
internal RouteMask(HttpMethod method, RouteMaskSegment[] segments) { Method = method; Segments = segments; Query = ""; }