Skip to content

Commit 4dfecfe

Browse files
authored
Merge pull request #78 from jehhynes/master
BREAKING CHANGE use form style arrays instead of comma delimited
2 parents 57ed1e8 + b1d060b commit 4dfecfe

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Griddly.Mvc/GriddlyExtensions.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static IDictionary<string, object> ObjectToDictionary(object value)
199199
public static string Current(this UrlHelper helper, object routeValues = null, bool includeQueryString = false)
200200
{
201201
RouteValueDictionary values = new RouteValueDictionary();
202-
202+
StringBuilder arrayVals = new StringBuilder();
203203
foreach (KeyValuePair<string, object> value in helper.RequestContext.RouteData.Values)
204204
{
205205
if (value.Value != null)
@@ -212,7 +212,9 @@ public static string Current(this UrlHelper helper, object routeValues = null, b
212212
// values[value.Key] = (DateTime)value.Value; -- BAD: can't unbox a value type as a different type
213213
values[value.Key] = Convert.ChangeType(value.Value, typeof(DateTime));
214214
else if (t.IsArray || t.IsSubclassOf(typeof(IEnumerable)))
215-
values[value.Key] = string.Join(",", ((IEnumerable)value.Value).Cast<object>());
215+
{
216+
arrayVals.Append(string.Join("&", ((IEnumerable)value.Value).Cast<object>().Select(x=> value.Key + "=" + x.ToString())));
217+
}
216218
}
217219
}
218220

@@ -239,7 +241,12 @@ public static string Current(this UrlHelper helper, object routeValues = null, b
239241
}
240242
}
241243

242-
return helper.RouteUrl(values);
244+
var route = helper.RouteUrl(values);
245+
if(arrayVals.Length>0)
246+
{
247+
route += (route.Contains("?") ? "&" : "?") + arrayVals.ToString();
248+
}
249+
return route;
243250
}
244251

245252
static readonly PropertyInfo _instrumentationService = typeof(WebPageExecutingBase).GetProperty("InstrumentationService", BindingFlags.NonPublic | BindingFlags.Instance);

0 commit comments

Comments
 (0)