Skip to content

Commit

Permalink
1. started regex for outbound rule replacement
Browse files Browse the repository at this point in the history
2. added server variables for url rewrite debugger
  • Loading branch information
iamandycohen committed Dec 29, 2014
1 parent 6ff9daa commit ac2c8ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Hi.UrlRewrite/Processing/OutboundRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ private OutboundRuleResult ProcessRegularExpressionOutboundRule(OutboundRuleResu
var replacements = new RewriteHelper.Replacements
{
RequestHeaders = RequestHeaders,
RequestServerVariables = RequestServerVariables
RequestServerVariables = RequestServerVariables,
ResponseHeaders = ResponseHeaders
};

conditionMatchResult = RewriteHelper.TestConditionMatches(outboundRule, replacements, out lastConditionMatch);
Expand All @@ -135,7 +136,7 @@ private OutboundRuleResult ProcessRegularExpressionOutboundRule(OutboundRuleResu
private bool TestRuleMatches(string responseString, OutboundRule outboundRule, out Match outboundRuleMatch)
{
// TODO: test against all of the "match the content within"

string regexPattern = @"<{0}((\s+\w+(\s*=\s*(?:"".*?""|'.*?'|[^'"">\s]+))?)+\s*|\s*)\/?>";

outboundRuleMatch = new Regex(@"").Match(@"");
return true;
Expand Down
14 changes: 12 additions & 2 deletions Hi.UrlRewrite/sitecore modules/Shell/UrlRewrite/Default.aspx.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.UI;
Expand Down Expand Up @@ -54,8 +55,17 @@ protected void Page_Load(object sender, EventArgs e)
using (new SiteContextSwitcher(siteContext))
using (new DatabaseSwitcher(_db))
{
results = rewriter.ProcessRequestUrl(new Uri(txtUrl.Text), inboundRules);

var url = new Uri(txtUrl.Text);
rewriter.RequestServerVariables = new NameValueCollection
{
{ "HTTP_HOST", url.Host},
{ "HTTPS", url.Scheme.Equals(Uri.UriSchemeHttps) ? "on" : "off" }
};
if (url.Query.Length > 0)
{
rewriter.RequestServerVariables.Add("QUERY_STRING", url.Query.Remove(0, 1));
}
results = rewriter.ProcessRequestUrl(url, inboundRules);
}

if (results == null)
Expand Down

0 comments on commit ac2c8ba

Please sign in to comment.