Permalink
Browse files

* fix FacebookWebHelper.DropQueryStrings if it contains fragment.

  • Loading branch information...
1 parent 11d69b0 commit a3b03607988a4d67153cab2e13657eb2998cbc31 @prabirshrestha committed Dec 8, 2011
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/Nancy.Facebook/FacebookWebHelper.cs
@@ -207,6 +207,15 @@ public static bool DropQueryStrings(string url, out string newUrl, string queryS
newRedirectUri.Append(redirectUriSplit[0]);
newRedirectUri.Append('?');
+ string fragment = null;
+ // contains fragment
+ if (redirectUriSplit[1].Contains('#'))
+ {
+ var fragmentIndex = redirectUriSplit[1].LastIndexOf('#');
+ fragment = redirectUriSplit[1].Substring(fragmentIndex);
+ redirectUriSplit[1] = redirectUriSplit[1].Substring(0, fragmentIndex);
+ }
+
var queryStrings = redirectUriSplit[1].Split('&');
foreach (var qs in queryStrings)
{
@@ -221,6 +230,11 @@ public static bool DropQueryStrings(string url, out string newUrl, string queryS
}
newRedirectUri.Length--;
+
+ // don't add fragment added by Facebook
+ if (returnValue && !string.IsNullOrEmpty(fragment) && fragment != "#_=_")
+ newRedirectUri.Append(fragment);
+
newUrl = newRedirectUri.ToString();
}
else

0 comments on commit a3b0360

Please sign in to comment.