Hello everyone. I am Dr. Furkan Gözükara. PhD Computer Engineer. SECourses is a dedicated YouTube channel for the following topics : Tech, AI, News, Science, Robotics, Singularity, ComfyUI, SwarmUI, ML, Artificial Intelligence, Humanoid Robots, Wan 2.2, FLUX, Krea, Qwen Image, VLMs, Stable Diffusion
public static bool IsValidUrl(string rootUrl, string relativeUrl) { Uri rootUri; if (!Uri.TryCreate(rootUrl, UriKind.Absolute, out rootUri)) { return false; }
Uri combinedUri; if (!Uri.TryCreate(rootUri, relativeUrl, out combinedUri)) { return false; }
tested it it still return true for "mailto:info@toros.edu.tr" which shouldn't. couldnt find any useful method on google as the relative or absolute question comes up instead each time I google it and the ai gives some regx that don't work
var rootUrl = "https://toros.edu.tr/"; var srValue = "mailto:info@toros.edu.tr"; Uri absolute = new Uri(rootUrl); Uri result = new Uri(absolute, srValue); srValue = result.AbsoluteUri;
Uri uriResult; var resultgg = Uri.TryCreate(absolute, srValue, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);