public static string GetCanonicalPath(string path) { if (PathValidator.IsValidLocalPath(path) || (PathValidator.IsValidUncPath(path))) { return(Path.GetFullPath(EnsureTrailingSlash(path))); } if (PathValidator.IsValidUrl(path)) { var url = new Uri(path); // return canonical representation of Uri return(url.AbsoluteUri); } return(path); }
/// <summary> /// Validates that a source is a valid path or url. /// </summary> /// <param name="source">The path to validate.</param> /// <returns>True if valid, False if invalid.</returns> public static bool IsValidSource(string source) { return(PathValidator.IsValidLocalPath(source) || PathValidator.IsValidUncPath(source) || PathValidator.IsValidUrl(source)); }
public static string GetCanonicalPath(string path) => ((PathValidator.IsValidLocalPath(path) || PathValidator.IsValidUncPath(path)) ? Path.GetFullPath(EnsureTrailingSlash(path)) : (!PathValidator.IsValidUrl(path) ? path : new Uri(path).AbsoluteUri));