From 8f29ae08d88af206cbaaf0f1cefd9bc44bc56a82 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 6 Jun 2017 14:03:40 -0500 Subject: [PATCH] (GH-1325) List/Search - no fail on local directory When looking at listing verbose information as you see with `choco info`, if the directory was a local file directory, the command would fail with the following error: `System.UriFormatException: Invalid URI: The format of the URI could not be determined.` This is due to the way that choco loads up package results, attempting to convert sources to Uris. Local file and relative directories don't adjust to a URI very well and cause the above error. When that happens, simply use the source as it is already set. --- .../infrastructure/results/PackageResult.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure/results/PackageResult.cs b/src/chocolatey/infrastructure/results/PackageResult.cs index 0802eb1406..c6e30f5486 100644 --- a/src/chocolatey/infrastructure/results/PackageResult.cs +++ b/src/chocolatey/infrastructure/results/PackageResult.cs @@ -51,9 +51,19 @@ public PackageResult(IPackage package, string installLocation, string source = n var sources = new List(); if (!string.IsNullOrEmpty(source)) { - sources.AddRange(source.Split(new[] {";", ","}, StringSplitOptions.RemoveEmptyEntries).Select(s => new Uri(s))); + try + { + sources.AddRange(source.Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => new Uri(s))); + } + catch (Exception ex) + { + this.Log().Debug("Unable to determine sources from '{0}'. Using value as is.{1} {2}".format_with(source, Environment.NewLine, ex.to_string())); + // source is already set above + return; + } } + var rp = Package as DataServicePackage; if (rp != null && rp.DownloadUrl != null) {