Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Nancy.Url no longer contains a fragment property #1421

Merged
merged 4 commits into from
Mar 16, 2014
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
1 change: 0 additions & 1 deletion src/Nancy.Hosting.Aspnet/NancyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private static Request CreateNancyRequest(HttpContextBase context)
BasePath = basePath,
Path = path,
Query = context.Request.Url.Query,
Fragment = context.Request.Url.Fragment,
};
byte[] certificate = null;

Expand Down
1 change: 0 additions & 1 deletion src/Nancy.Hosting.Self/NancyHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ private Request ConvertRequestToNancyRequest(HttpListenerRequest request)
BasePath = baseUri.AbsolutePath.TrimEnd('/'),
Path = HttpUtility.UrlDecode(relativeUrl),
Query = request.Url.Query,
Fragment = request.Url.Fragment,
};

byte[] certificate = null;
Expand Down
1 change: 0 additions & 1 deletion src/Nancy.Tests/Unit/Security/ModuleSecurityFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ private static Url GetFakeUrl(bool https)
return new Url
{
BasePath = null,
Fragment = string.Empty,
HostName = "localhost",
Path = "/",
Port = 80,
Expand Down
33 changes: 7 additions & 26 deletions src/Nancy.Tests/Unit/UrlFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,6 @@ public void Should_append_question_mark_to_querystring_when_missing()
result.ShouldEndWith("https://www.nancyfx.org:1234/base?foo=some%20text");
}

[Fact]
public void Should_append_fragment_when_converting_to_string()
{
// Given
this.url.Scheme = "https";
this.url.HostName = "www.nancyfx.org";
this.url.Port = 1234;
this.url.BasePath = "/base";
this.url.Path = "/";
this.url.Query = "?foo=some%20text";
this.url.Fragment = "anchor";

// When
var result = this.url.ToString();

// Then
result.ShouldEndWith("https://www.nancyfx.org:1234/base?foo=some%20text#anchor");
}

[Fact]
public void Should_implicitliy_cast_from_string()
{
Expand All @@ -207,7 +188,6 @@ public void Should_implicitliy_cast_from_string()
result.BasePath.ShouldBeNull();
result.Path.ShouldEqual("/base");
result.Query.ShouldEqual("?foo=some%20text");
//result.Fragment.ShouldBeNull();
}

[Fact]
Expand All @@ -220,13 +200,12 @@ public void Should_implicitliy_cast_to_string()
this.url.BasePath = "/base";
this.url.Path = "/";
this.url.Query = "?foo=some%20text";
this.url.Fragment = "anchor";

// When
string result = this.url;

// Then
result.ShouldEqual("https://www.nancyfx.org:1234/base?foo=some%20text#anchor");
result.ShouldEqual("https://www.nancyfx.org:1234/base?foo=some%20text");
}

[Fact]
Expand All @@ -245,7 +224,6 @@ public void Should_implicitliy_cast_from_uri()
result.BasePath.ShouldBeNull();
result.Path.ShouldEqual("/base");
result.Query.ShouldEqual("?foo=some%20text");
//result.Fragment.ShouldBeNull();
}

[Fact]
Expand All @@ -258,13 +236,17 @@ public void Should_implicitliy_cast_to_uri()
this.url.BasePath = "/base";
this.url.Path = "/";
this.url.Query = "?foo=some%20text";
this.url.Fragment = "anchor";

// When
Uri result = this.url;

// Then
result.ToString().ShouldEqual("https://www.nancyfx.org:1234/base?foo=some text#anchor");
result.Scheme.ShouldEqual("https");
result.Host.ShouldEqual("www.nancyfx.org");
result.Port.ShouldEqual(1234);
result.AbsolutePath.ShouldEqual("/base");
result.Query.ShouldEqual("?foo=some%20text");
result.Fragment.ShouldBeEmpty();
}

[Fact]
Expand All @@ -277,7 +259,6 @@ public void Should_implicitly_cast_to_absolute_uri()
this.url.BasePath = "/base";
this.url.Path = "/";
this.url.Query = "?foo=some%20text";
this.url.Fragment = "anchor";

// When
Uri result = this.url;
Expand Down
17 changes: 3 additions & 14 deletions src/Nancy/Url.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace Nancy
using System.Net.Sockets;

/// <summary>
/// Represents a full Url of the form scheme://hostname:port/basepath/path?query#fragment
/// Represents a full Url of the form scheme://hostname:port/basepath/path?query
/// </summary>
/// <remarks>Since this is for internal use, and fragments are not passed to the server, fragments are not supported.</remarks>
public sealed class Url : ICloneable
{
private string basePath;
Expand All @@ -22,7 +23,6 @@ public Url()
this.BasePath = String.Empty;
this.Path = String.Empty;
this.Query = String.Empty;
this.Fragment = String.Empty;
}

/// <summary>
Expand Down Expand Up @@ -69,10 +69,6 @@ public string BasePath
/// </summary>
public string Query { get; set; }

/// <summary>
/// Gets the fragment of the request
/// </summary>
public string Fragment { get; set; }

/// <summary>
/// Gets the domain part of the request
Expand Down Expand Up @@ -105,8 +101,7 @@ public override string ToString()
GetPort(this.Port) +
GetCorrectPath(this.BasePath) +
GetCorrectPath(this.Path) +
GetQuery(this.Query) +
GetFragment(this.Fragment);
GetQuery(this.Query);
}

private static string GetQuery(string query)
Expand Down Expand Up @@ -139,7 +134,6 @@ public Url Clone()
return new Url
{
BasePath = this.BasePath,
Fragment = this.Fragment,
HostName = this.HostName,
Port = this.Port,
Query = this.Query,
Expand Down Expand Up @@ -197,11 +191,6 @@ public static implicit operator Url(Uri uri)
return url;
}

private static string GetFragment(string fragment)
{
return (string.IsNullOrEmpty(fragment)) ? string.Empty : string.Concat("#", fragment);
}

private static string GetCorrectPath(string path)
{
return (string.IsNullOrEmpty(path) || path.Equals("/")) ? string.Empty : path;
Expand Down