Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Tests/HttpUnitTests/UriUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ public void UriCtor_Should_Not_Throw_Exception(string uri)
Assert.IsNotNull(createdUri);
}

[DataRow("http://user:[email protected]/Home", "Index.html?q1=v1&q2=v2#FragmentName", "http://user:[email protected]/Home/Index.html?q1=v1&q2=v2#FragmentName")]
[DataRow("http://user:[email protected]/Home/", "Index.html?q1=v1&q2=v2#FragmentName", "http://user:[email protected]/Home/Index.html?q1=v1&q2=v2#FragmentName")]
[DataRow("http://user:[email protected]/Home", "/Index.html?q1=v1&q2=v2#FragmentName", "http://user:[email protected]/Home/Index.html?q1=v1&q2=v2#FragmentName")]
[DataRow("http://user:[email protected]/Home/", "/Index.html?q1=v1&q2=v2#FragmentName", "http://user:[email protected]/Home/Index.html?q1=v1&q2=v2#FragmentName")]
public void UriWithParamaters(string uri, string paramaters, string correctFullUri)
{
Uri baseUri = new(uri);
Uri fullUri = new(correctFullUri);
Uri parmUri = new(paramaters, UriKind.Relative);
Uri finalUri = new(baseUri, parmUri.OriginalString);
Console.WriteLine($"{finalUri.OriginalString} == {fullUri.OriginalString}");
Assert.AreEqual(finalUri.OriginalString, correctFullUri);
Assert.AreEqual(fullUri.OriginalString, correctFullUri);
}

[TestMethod]
[DataRow("", typeof(ArgumentNullException), "ExpectedArgumentNullException")]
[DataRow("foo", typeof(ArgumentException), "Expected ArgumentException")]
Expand Down Expand Up @@ -467,3 +482,4 @@ private static void PrintUriPropertiesToConsole(Uri uri)
}
}
}

7 changes: 5 additions & 2 deletions nanoFramework.System.Net.Http/Http/System.Uri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,11 @@ public Uri(
{
throw new FormatException();
}

ConstructAbsoluteUri(baseUri.AbsoluteUri + relativeUri);

// We need to have http://myuri/relative and sometimes the / is missing
var baseadj = baseUri.AbsoluteUri.EndsWith("/") ? baseUri.AbsoluteUri : baseUri.AbsoluteUri + "/";
var relativeadj = relativeUri.StartsWith("/") ? relativeUri.Substring(1) : relativeUri;
ConstructAbsoluteUri(baseadj + relativeadj);
}

/// <summary>
Expand Down